<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" encoding="windows-1250" indent="yes"/>

  <xsl:param name="cviewcode"/>
  <xsl:param name="readonly" select="$cviewcode/@ro"/>

  <xsl:param name="pagelen">50</xsl:param>

  <xsl:template match="/">
    <DPPackage debug="no">
      <Descr>Mambo 3.0 Generated Package (c) 2005 Metada s.r.o</Descr>
      <xsl:apply-templates select="$cviewcode/.././/CVInclude[@virtual='0' and count(ancestor::CVInclude[@virtual='1'])=0]"/>

      <xsl:for-each select="$cviewcode/../CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']/Schedules/UpdateSchedule/SchedItem[position()=last()]">
        <Dataport code="updrecroot">
          <InData>
            <InParam code="child"/>
          </InData>
          <Process>
            <WhileNot code="child" contains="" max="10">
              <Debug name="x">
                <OutParam source="child"/>
              </Debug>
              <Copy source="child" target="childlast"/>
              <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="it">
                <Where>
                  <xsl:for-each select="../../../CVIRels/CVIRel[CVInclude/@path='../..']/CVIRBindings/CVIRBinding">
                    <Eq param="child" property="{@p1}"/>
                  </xsl:for-each>
                </Where>
              </GetData>
              <GetElement from="it" into="child" path="/{@concept}s/{@concept}/@{ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding/@p2low}"/>
            </WhileNot>
            <CreateDoc code="root" doctype="{ancestor::CView/CVInclude/@concept}"/>
            <UseDoc code="root">
              <AddAttr name="{ancestor::CView/CVInclude/Keys/Binding/@propertylow}" src="child"/>
            </UseDoc>
            <UpdateData concept="{ancestor::CView/CVInclude/@concept}" insert="no" rights="true" update="yes" with="root" work="{ancestor::CView/@name}" workpath="/{ancestor::CView/CVInclude/@concept}"/>
          </Process>
          <OutData type="xml">
            <Output id="done" source="res" optional="yes"/>
          </OutData>
        </Dataport>
      </xsl:for-each>

    </DPPackage>
  </xsl:template>

  <xsl:template match="CVInclude">
    <!--
      <xsl:variable name="ro_redir">
        <xsl:if test="$readonly='1'">../../<xsl:value-of select="concat(ancestor::CView/@package,'/',ancestor::CView/@name,'/')"/></xsl:if>
      </xsl:variable>
    -->
    <xsl:variable name="ro_redir"></xsl:variable>
    <xsl:variable name="id_cvinclude"><xsl:value-of select="@id_cvinclude"/></xsl:variable>
    <xsl:variable name="this_cvinclude" select="."/>
    <xsl:variable name="id_cvincludeparent"><xsl:value-of select="@id_cvincludeparent"/></xsl:variable>
    <xsl:variable name="cvirbindings" select="../CVIRBindings/CVIRBinding"/>
    <xsl:variable name="deforderby">
      <xsl:choose>
        <xsl:when test="starts-with(@deforderby,'-')"><xsl:value-of select="substring-after(@deforderby,'-')"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="@deforderby"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="deforder">
      <xsl:choose>
        <xsl:when test="starts-with(@deforderby,'-')">desc</xsl:when>
        <xsl:otherwise>asc</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="isdistinct">
      <xsl:choose>
        <xsl:when test="@isdistinct='1'">true</xsl:when>
        <xsl:otherwise>false</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <Dataport code="list{@id_cvinclude}">
      <InData>
        <InParam code="{@concept}.step" optional="yes">
        <xsl:choose>
          <xsl:when test="not(@pagestep)">
            <xsl:attribute name="default"><xsl:value-of select="$pagelen"/></xsl:attribute>
          </xsl:when>
          <xsl:when test="@pagestep &gt; 0">
            <xsl:attribute name="default"><xsl:value-of select="@pagestep"/></xsl:attribute>
          </xsl:when>
        </xsl:choose>
        </InParam>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p1}"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
        <InParam code="{@concept}.start" optional="yes"/>
        <InParam code="{@concept}.orderby" optional="yes"/>
        <InParam code="{@concept}.order" optional="yes"/>
        <InParam code="{@concept}.filterfirst" default="{@filterfirst}" optional="yes"/>
        <InParam code="style" default="1" optional="yes"/>
        <InParam code="allowmulti" default="0" optional="yes"/>
        <InDoc doctype="DPFilter" code="{@concept}.filter" optional="yes"/>
        <InDoc doctype="DPFilter" code="filter" optional="yes"/>
        <InParam code="setfilter" optional="yes"/>
        <InParam code="select" default="no"/>
        <InParam code="norec" optional="yes"/>
      </InData>
      <Process>
        <IfNot code="filter" contains="">
          <CreateDoc doctype="DPFilter" code="{@concept}.filter"/>
          <UpdateElement in="{@concept}.filter" path="/DPFilter" src="filter"/>
        </IfNot>
        <SessionStore code="select" src="select" scope="dp"/>
        <SessionStore code="{@concept}.step" src="{@concept}.step" scope="dp"/>
        <SessionStore code="{@concept}.filterfirst" src="{@concept}.filterfirst" scope="dp"/>
        <SessionStore code="style" src="style" scope="dp"/>
        <SessionStore code="allowmulti" src="allowmulti" scope="dp"/>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <SessionStore code="{@p1}" src="{@p1}" scope="dp"/>
          <SessionStore code="{@p1}" src="{@p1}" scope="friend" friend="updatelist{$id_cvinclude}"/>
        </xsl:for-each>
        <xsl:variable name="propprefix">
          <xsl:choose>
            <xsl:when test="@treelist='1' and name(..)='CView'">/<xsl:value-of select="@concept"/>/</xsl:when>
            <xsl:otherwise></xsl:otherwise>
          </xsl:choose>
        </xsl:variable>

        <Copy target="nofilter" default="no"/>

        <If code="{@concept}.filter" contains="">
          <Copy target="nofilter" default="yes"/>
          <xsl:if test="count(CVIProperties/CVIProperty[@onfilter='show' and DefaultFilter and DefaultFilter!=''])>0">
            <CreateDoc code="{@concept}.filter" doctype="DPFilter"/>
            <xsl:for-each select="CVIProperties/CVIProperty[@onfilter='show' and DefaultFilter and DefaultFilter!='']">
              <xsl:choose>
                <xsl:when test="not(RefProp) or (@ref!='' and @fetchtype='direct')">
                  <xsl:choose>
                    <xsl:when test="@type='int' or @type='float' or @type='boolean' or @type='boolean_txt'">
                          <CreateDoc code="x" doctype="Eq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                    </xsl:when>
                    <xsl:when test="@type='date' or @type='datetime' or @type='timestamp'">
                          <CreateDoc code="x" doctype="GtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_from"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                          <CreateDoc code="x" doctype="LtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_to"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                    </xsl:when>
                    <xsl:otherwise>
                          <CreateDoc code="x" doctype="Like"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:when>
              </xsl:choose>
            </xsl:for-each>
          </xsl:if>
        </If>

        <If code="setfilter" contains="yes">
          <Copy target="nofilter" default="no"/>
          <IfNot code="{@concept}.noinit" contains="yes">
            <Copy target="{@concept}.start" default="1"/>
          </IfNot>
          <CreateDoc code="{@concept}.filter" doctype="DPFilter"/>
          <xsl:for-each select="CVIProperties/CVIProperty[@onfilter='show' or @onlist='show']">
            <xsl:choose>
              <xsl:when test="not(RefProp)">
                <xsl:choose>
                  <xsl:when test="@type='int' or @type='float' or @type='boolean' or @type='boolean_txt'">
                      <IfNot code="{@formcode}" contains="">
                        <If code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="IsNull"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                          </UseDoc>
                        </If>
                        <IfNot code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="Eq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" src="{@formcode}"/>
                          </UseDoc>
                        </IfNot>
                        <UseDoc code="{../../@concept}.filter">
                          <AddDoc src="x"/>
                        </UseDoc>
                      </IfNot>
                  </xsl:when>
                  <xsl:when test="@type='date' or @type='datetime' or @type='timestamp'">
                      <If code="{@formcode}_from" contains="!">
                        <CreateDoc code="x" doctype="IsNull"/>
                        <UseDoc code="x">
                          <AddAttr name="property" default="{$propprefix}{@name}"/>
                          <AddAttr name="nick" default="{$propprefix}{@name}_from"/>
                        </UseDoc>
                        <UseDoc code="{../../@concept}.filter">
                          <AddDoc src="x"/>
                        </UseDoc>
                      </If>
                      <IfNot code="{@formcode}_from" contains="!">
                        <IfNot code="{@formcode}_from" contains="">
                          <CreateDoc code="x" doctype="GtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_from"/>
                            <AddAttr name="default" src="{@formcode}_from"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                        </IfNot>
                        <IfNot code="{@formcode}_to" contains="">
                          <CreateDoc code="x" doctype="LtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_to"/>
                            <AddAttr name="default" src="{@formcode}_to"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                        </IfNot>
                      </IfNot>
                  </xsl:when>
                  <xsl:otherwise>
                      <IfNot code="{@formcode}" contains="">
                        <If code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="IsNull"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                          </UseDoc>
                        </If>
                        <IfNot code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="Like"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" src="{@formcode}"/>
                          </UseDoc>
                        </IfNot>
                        <UseDoc code="{../../@concept}.filter">
                          <AddDoc src="x"/>
                        </UseDoc>
                      </IfNot>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>
              <xsl:otherwise>
                <IfNot code="{@formcode}" contains="">
                  <If code="{@formcode}" contains="!">
                    <CreateDoc code="x" doctype="IsNull"/>
                    <UseDoc code="x">
                      <AddAttr name="property" default="{@nickname}"/>
                    </UseDoc>
                  </If>
                  <IfNot code="{@formcode}" contains="!">
                  <xsl:choose>
                    <xsl:when test="@type='int' or @type='float' or @type='date' or @type='datetime' or @type='timestamp' or @type='boolean' or @type='boolean_txt'">
                      <CreateDoc code="x" doctype="Eq"/>
                      <UseDoc code="x">
                        <AddAttr name="property" default="{@nickname}"/>
                        <AddAttr name="default" src="{@formcode}"/>
                      </UseDoc>
                    </xsl:when>
                    <xsl:otherwise>
                      <CreateDoc code="x" doctype="Like"/>
                      <UseDoc code="x">
                        <AddAttr name="property" default="{@nickname}"/>
                        <AddAttr name="default" src="{@formcode}"/>
                      </UseDoc>
                    </xsl:otherwise>
                  </xsl:choose>
                  </IfNot>
                  <UseDoc code="{../../@concept}.filter">
                    <AddDoc src="x"/>
                  </UseDoc>
                </IfNot>
                <xsl:for-each select="RefProp">
                  <IfNot code="{../@formcode}{@formcode}" contains="">
                    <If code="{../@formcode}{@formcode}" contains="!">
                      <CreateDoc code="x" doctype="IsNull"/>
                      <UseDoc code="x">
                        <AddAttr name="property" default="{../@nickname}.{@refconcept}/{@code}"/>
                      </UseDoc>
                    </If>
                    <IfNot code="{../@formcode}{@formcode}" contains="!">
                    <xsl:choose>
                      <xsl:when test="@type='int' or @type='float' or @type='date' or @type='datetime' or @type='timestamp' or @type='boolean' or @type='boolean_txt'">
                        <CreateDoc code="x" doctype="Eq"/>
                        <UseDoc code="x">
                          <AddAttr name="property" default="{../@nickname}.{@refconcept}/{@code}"/>
                          <AddAttr name="default" src="{../@formcode}{@formcode}"/>
                        </UseDoc>
                      </xsl:when>
                      <xsl:otherwise>
                        <CreateDoc code="x" doctype="Like"/>
                        <UseDoc code="x">
                          <AddAttr name="property" default="{../@nickname}.{@refconcept}/{@code}"/>
                          <AddAttr name="default" src="{../@formcode}{@formcode}"/>
                        </UseDoc>
                      </xsl:otherwise>
                    </xsl:choose>
                    </IfNot>
                    <UseDoc code="{../../../@concept}.filter">
                      <AddDoc src="x"/>
                    </UseDoc>
                  </IfNot>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:for-each>
        </If>

        <Call dataport="{@concept}{@id_cvinclude}_LIST" into="{@concept}{@id_cvinclude}_LIST">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <SendParam code="{@p2}" source="{@p1}"/>
          </xsl:for-each>
          <SendParam code="{@concept}.start" optional="yes"/>
          <SendParam code="{@concept}.step" optional="yes"/>
          <SendParam code="{@concept}.orderby" optional="yes"/>
          <SendParam code="{@concept}.order" optional="yes"/>
          <SendParam code="{@concept}.filter" optional="yes"/>
          <SendParam code="{@concept}.filterfirst" optional="yes"/>
          <SendParam code="select" default="no"/>
        </Call>

        <xsl:if test="@required!='*' and @jumpstodetail='1'">
        <If code="nofilter" contains="yes">
          <UseDoc code="{@concept}{@id_cvinclude}_LIST">
            <GetDoc name="DPPage" into="dppage" clone="no"/>
            <GetDoc name="{@conceptcoll}" into="col" clone="no"/>
          </UseDoc>
          <UseDoc code="dppage">
            <GetAttr name="total" into="cnt" default="x"/>
          </UseDoc>
          <If code="cnt" contains="1">
            <UseDoc code="col">
              <GetDoc name="{@concept}" into="c" clone="no"/>
            </UseDoc>
            <UseDoc code="c">
              <xsl:for-each select="Keys/Binding">
                <GetAttr name="{@propertylow}" into="{@property}"/>
              </xsl:for-each>
            </UseDoc>
            <DoOutput ref="one_go_edit"/>
          </If>
          <If code="cnt" contains="0">
            <DoOutput ref="one_go_create"/>
          </If>
        </If>
        </xsl:if>

        <xsl:if test="@required='*' and @jumpstodetail='1'">
        <If code="nofilter" contains="yes">
          <UseDoc code="{@concept}{@id_cvinclude}_LIST">
            <GetDoc name="DPPage" into="dppage" clone="no"/>
            <GetDoc name="{@conceptcoll}" into="col" clone="no"/>
          </UseDoc>
          <UseDoc code="dppage">
            <GetAttr name="total" into="cnt" default="x"/>
          </UseDoc>
          <If code="cnt" contains="1">
            <UseDoc code="col">
              <GetDoc name="{@concept}" into="c" clone="no"/>
            </UseDoc>
            <UseDoc code="c">
              <xsl:for-each select="Keys/Binding">
                <GetAttr name="{@propertylow}" into="{@property}"/>
              </xsl:for-each>
            </UseDoc>
            <DoOutput ref="one_go_edit"/>
          </If>
        </If>
        </xsl:if>

        <CreateDoc code="navig" doctype="DPNavig"/>

        <xsl:for-each select="ancestor::CVInclude">
           <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
             <xsl:for-each select="$cvirbindings">
               <SendParam code="{@p1}"/>
             </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
           </Call>
           <UseDoc code="navig">
             <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
           </UseDoc>
        </xsl:for-each>


        <UseDoc code="{@concept}{@id_cvinclude}_LIST">
          <AddAttr name="style" src="style"/>
          <AddAttr name="allowmulti" src="allowmulti"/>
          <AddAttr name="norec" src="norec"/>
        </UseDoc>

        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='list'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='list' and position()&gt;1]">
            <If code="style">
              <xsl:attribute name="contains"><xsl:value-of select="position()+1"/></xsl:attribute>
              <DoOutput>
                <xsl:attribute name="ref">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              </DoOutput>
            </If>
          </xsl:for-each>
        </xsl:if>

      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}{@id_cvinclude}_LIST"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="list{@id_cvinclude}.xsl" hrefparam="ssnstllst" hrefsuffix="{@id_cvinclude}.xsl"/>
          <xsl:if test="name(..)!='CView'">
            <Template href="{$ro_redir}flap{../../../@id_cvinclude}.xsl"/>
          </xsl:if>
        </Output>
        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='list'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='list' and position()&gt;1]">
            <Output>
              <xsl:attribute name="id">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              <OutDoc source="{../../@concept}{../../@id_cvinclude}_LIST"/>
              <OutDoc source="navig" optional="yes"/>
              <Template href="/header.xsl"/>
              <Template hrefparam="ssnstllst">
                <xsl:attribute name="href">list<xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
                <xsl:attribute name="hrefsuffix"><xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
              </Template>
              <xsl:if test="name(../../..)!='CView'">
                <Template href="{$ro_redir}flap{../../../../../@id_cvinclude}.xsl"/>
              </xsl:if>
            </Output>
          </xsl:for-each>
        </xsl:if>
        <ChangeState id="one_go_edit" dataport="edit{@id_cvinclude}" external="yes">
          <xsl:for-each select="Keys/Binding">
            <OutParam code="{@property}"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p2}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <ChangeState id="one_go_create" dataport="create{@id_cvinclude}" external="yes">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <OutParam code="{@p2}" source="{@p1}"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p2}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>


    <Dataport code="{@concept}{@id_cvinclude}_LIST">
      <InData>
        <InParam code="{@concept}.step" optional="yes">
        <xsl:choose>
          <xsl:when test="not(@pagestep)">
            <xsl:attribute name="default"><xsl:value-of select="$pagelen"/></xsl:attribute>
          </xsl:when>
          <xsl:when test="@pagestep &gt; 0">
            <xsl:attribute name="default"><xsl:value-of select="@pagestep"/></xsl:attribute>
          </xsl:when>
        </xsl:choose>
        </InParam>
        <InParam code="{@concept}.start" optional="yes"/>
        <InParam code="{@concept}.orderby" default="{$deforderby}" optional="yes"/>
        <InParam code="{@concept}.order" default="{$deforder}" optional="yes"/>
        <InParam code="{@concept}.filterfirst" default="{@filterfirst}" optional="yes"/>
        <InParam code="select" default="no"/>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p2}"/>
        </xsl:for-each>
        <InDoc doctype="DPFilter" code="{@concept}.filter" optional="yes"/>
        <InParam code="norec" default="no"/>
      </InData>
      <Process>
        <SessionStore code="{@concept}.step" src="{@concept}.step" scope="dp"/>
        <SessionStore code="{@concept}.orderby" src="{@concept}.orderby" scope="dp"/>
        <SessionStore code="{@concept}.order" src="{@concept}.order" scope="dp"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="dp"/>
        <SessionStore code="{@concept}.orderby" src="{@concept}.orderby" scope="friend" friend="{@concept}{@id_cvinclude}_EXPLIST"/>
        <SessionStore code="{@concept}.order" src="{@concept}.order" scope="friend" friend="{@concept}{@id_cvinclude}_EXPLIST"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="friend" friend="{@concept}{@id_cvinclude}_EXPLIST"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="friend" friend="list{@id_cvinclude}"/>
        <SessionStore code="{@concept}.orderby" src="{@concept}.orderby" scope="friend" friend="{@concept}{@id_cvinclude}_PRINT"/>
        <SessionStore code="{@concept}.order" src="{@concept}.order" scope="friend" friend="{@concept}{@id_cvinclude}_PRINT"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="friend" friend="{@concept}{@id_cvinclude}_PRINT"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="friend" friend="print{@id_cvinclude}"/>

        <IfNot code="{@concept}.filterfirst" contains="1">
        <xsl:choose>
          <xsl:when test="@treelist='1' and name(..)='CView'">          
          <If code="norec" contains="yes">
            <GetData conceptview="{ancestor::CView/@name}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist" scope="treelist">
              <Where>
                <xsl:if test="name(..)!='CView'">
                  <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                    <Eq property="{@p2}" param="{@p2}"/>
                  </xsl:for-each>
                </xsl:if>
              </Where>
            </GetData>                    
          </If>
          <If code="norec" contains="no">
            <GetData conceptview="{ancestor::CView/@name}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist" scope="treelist">
              <Where>
                <xsl:if test="name(..)!='CView'">
                  <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                    <Eq property="{@p2}" param="{@p2}"/>
                  </xsl:for-each>
                </xsl:if>
                <xsl:if test="@xxxrecursive='yes'">
                  <Eq property="xxxisroot" default="1"/>
                </xsl:if>
              </Where>
            </GetData>          
          </If>
          </xsl:when>
          <xsl:otherwise>
          <If code="norec" contains="yes">
            <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist">
              <Where>
                <xsl:if test="name(..)!='CView'">
                  <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                    <Eq property="{@p2}" param="{@p2}"/>
                  </xsl:for-each>
                </xsl:if>
              </Where>
            </GetData>          
          </If>
          <If code="norec" contains="no">
		<xsl:choose>

		  <xsl:when test="$cvirbindings/@inhassocmember='1'">
    	          <xsl:variable name="assocnode" select="../../CVIRel[CVIRBindings/CVIRBinding/@inhassoc = '1']/CVInclude"/>
    	            <!-- paging is not supported for classed listings" -->
    	            <Eval default="-1" target="{@concept}.step" type="string"/>
   		    <Call dataport="getAncestors{$assocnode/@id_cvincludeparent}_{$assocnode/@id_cvinclude}" into="Parents">
 		      <SendParam code="{../CVIRBindings/CVIRBinding/@p1}" source="{../CVIRBindings/CVIRBinding/@p2}"/>
   		    </Call>
   		    
	            <CreateDoc code="Classes" doctype="Classes"/>
                    <UseDoc code="Classes">
                      <AddAttr default="{../CVIRBindings/CVIRBinding/@p2low}" name="attribute" />
                    </UseDoc>

   		    <EnsureDoc code="{@concept}.filter" doctype="DPFilter"/>
   		    <CreateDoc code="Cond" doctype="SubCondition"/>
   		    <UseDoc code="Cond">
   		      <AddAttr name="type" default="or"/>
   		    </UseDoc>
   		    
   		    <ForEach elem="Parent" in="Parents" as="Parent" context="no">
   		      <UseDoc code="Parent">
   		        <GetAttr name="id" into="parentID"/>
                        <GetAttr name="name" into="parentName"/>
                        <GetAttr name="pos" into="parentPosition"/>
   		      </UseDoc>
   		      
   		      <CreateDoc code="Eq" doctype="Eq"/>
   		      <UseDoc code="Eq">
   		        <AddAttr default="{../CVIRBindings/CVIRBinding/@p2}" name="property"/>
   		        <AddAttr src="parentID" name="default"/>
   		      </UseDoc>
   		      
   		      <UseDoc code="Cond">
   		        <AddDoc src="Eq"/>
   		      </UseDoc>
   
                      <CreateDoc code="Class" doctype="Class"/>
                      <UseDoc code="Class">
                        <AddAttr name="value" src="parentID"/>
                        <AddAttr name="caption" src="parentName"/>
                        <AddAttr name="position" src="parentPosition"/>
                      </UseDoc>
                      <UseDoc code="Classes">
                        <AddDoc src="Class"/>
                      </UseDoc>

  		    </ForEach>
  		    
  		    <CreateDoc code="Eq" doctype="Eq"/>
   		    <UseDoc code="Eq">
  		      <AddAttr default="{../CVIRBindings/CVIRBinding/@p2}" name="property"/>
  		      <AddAttr src="{../CVIRBindings/CVIRBinding/@p2}" name="default"/>
   		    </UseDoc>
	    
 		    <UseDoc code="Cond">
 		      <AddDoc src="Eq"/>
 		    </UseDoc>
 		    
 		    <UseDoc code="{@concept}.filter">
 		      <AddDoc src="Cond"/>
 		    </UseDoc>
 		    
 		    <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist"/>
 		    
		  </xsl:when>

		  <xsl:otherwise>
                <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist">
                   <Where>
                     <xsl:if test="name(..)!='CView'">
                       <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                         <Eq property="{@p2}" param="{@p2}"/>
                       </xsl:for-each>
                     </xsl:if>
                     <xsl:if test="name(..)='CView'">
                      <xsl:if test="@xxxrecursive='yes'">
                        <Eq property="xxxisroot" default="1"/>
                      </xsl:if>
                     </xsl:if>
                   </Where>
                 </GetData>          
		  </xsl:otherwise>

		</xsl:choose>
          </If>	                
          
          </xsl:otherwise>
        </xsl:choose>
        </IfNot>

        <EnsureDoc code="{@concept}.filter" doctype="DPFilter"/>
        <CreateDoc code="res" doctype="DPList"/>
        <UseDoc code="res">
          <AddDoc src="{@concept}.filter"/>
          <AddDoc src="{@concept}"/>
          <AddDoc src="{@concept}.dppage"/>
          <xsl:if test="$cvirbindings/@inhassocmember='1'">
            <AddDoc src="Classes"/>
          </xsl:if>
          <AddAttr name="order" src="{@concept}.order"/>
          <AddAttr name="orderby" src="{@concept}.orderby"/>
          <AddAttr name="name" default="{@concept}"/>
          <AddAttr name="selectfun" src="select"/>
          <AddAttr name="filterfirst" src="{@concept}.filterfirst"/>
        </UseDoc>

        <xsl:if test="CVIProperties/CVIProperty[(@onfilter='show' or (@onedit='show' and @onlist='show')) and @ref and @ref!='' and @fetchtype='direct']">
          <CreateDoc code="opts" doctype="Opts"/>

        <xsl:for-each select="CVIProperties/CVIProperty[(@onfilter='show' or (@onedit='show' and @onlist='show')) and @ref and @ref!='' and @fetchtype='direct' and (not(@extwork) or @extwork='')]">
          <xsl:variable name="attr">
            <xsl:choose>
              <xsl:when test="@attr='1'">true</xsl:when>
              <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:variable name="refc">
            <xsl:value-of select="@refconcept"/>
          </xsl:variable>
          <xsl:variable name="refp">
            <xsl:value-of select="@refprop"/>
          </xsl:variable>          
          <xsl:choose>          
            <xsl:when test="RefProp[@refconcept != $refc or @code != $refp]">
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                <Properties>
                  <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                  <xsl:for-each select="RefProp">
                    <xsl:variable name="rattr">
                      <xsl:choose>
                        <xsl:when test="@attr='1'">true</xsl:when>
                        <xsl:otherwise>false</xsl:otherwise>
                      </xsl:choose>
                    </xsl:variable>
                    <xsl:if test="@refconcept != $refc or @code != $refp">
                      <!-- TODO: PVI: fix the same situation in other dataports
                                      or (better) fix interm style
                           (duplicate properties in GetData when RefConcept has key with onlabel=true
                      -->
                      <Property name="{@refconcept}/{@code}" attr="{$rattr}"/>
                    </xsl:if>
                  </xsl:for-each>
                </Properties>
                <Orders>
                  <OrderBy type="asc"><Property name="{@refconcept}/{RefProp[1]/@code}"/></OrderBy>
                </Orders>
              </GetData>
            </xsl:when>
            <xsl:otherwise>
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                <Properties>
                  <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                </Properties>
                <Orders>
                  <OrderBy type="asc"><Property name="{@refconcept}/{@refprop}"/></OrderBy>
                </Orders>
              </GetData>
            </xsl:otherwise>
          </xsl:choose>

          <UseDoc code="opts">
            <AddDoc src="XXR_{@refconcept}"/>
          </UseDoc>

        </xsl:for-each>

        <xsl:for-each select="CVIProperties/CVIProperty[(@onfilter='show' or (@onedit='show' and @onlist='show')) and @ref and @ref!='' and @fetchtype='direct' and @extwork and @extwork!='']">

          <GetData conceptview="{@extwork}" into="XXR_{@refconcept}" path="/" rights="true" show="onlist" allkeys="true"/>

          <UseDoc code="opts">
            <AddDoc src="XXR_{@refconcept}"/>
          </UseDoc>

        </xsl:for-each>

        <UseDoc code="res">
          <AddDoc src="opts"/>
        </UseDoc>
        </xsl:if>

      </Process>
      <OutData type="xml">
        <Output source="res"/>
      </OutData>
    </Dataport>
  
 <!-- UPDATE START (Juraj Obert): Inheritance support-->
   <xsl:if test="$cvirbindings/@inhassoc = '1' ">
     <Dataport code="getAncestors{@id_cvincludeparent}_{@id_cvinclude}">
     <InData>
       <InParam code="{$cvirbindings/@p1}"/>
       <InParam code="counter" default="0"/>
     </InData>
     
     <Process>
     
     <EnsureDoc code="Parents" doctype="Parents"/>
     
     <xsl:variable name="assocnode" select="../../CVIRel[CVIRBindings/CVIRBinding/@inhassoc = '1']/CVInclude/@concept"/>
     <xsl:variable name="assocnodecoll" select="../../CVIRel[CVIRBindings/CVIRBinding/@inhassoc = '1']/CVInclude/@conceptcoll"/>
     
     <GetData concept="{$assocnode}" into="queryResultRoot" distinct="true">
     	<Where>
     	  <Eq property="{$cvirbindings/@p2}" param="{$cvirbindings/@p1}"/>
     	</Where>
     </GetData>   

     <If code="queryResultRoot" contains="{$assocnodecoll}/{$assocnode}">
       <UseDoc code="queryResultRoot">
         <GetDoc name="{$assocnode}" code="queryResultRoot" into="queryResult{$assocnode}"/>
       </UseDoc>
       
       <UseDoc code="queryResult{$assocnode}">
         <GetAttr name="{$cvirbindings/@inhref}" into="queryResultParent"/>
       </UseDoc>

       <CreateDoc code="Parent" doctype="Parent"/>
        
       <GetData concept="{../../../Concept/@name}" distinct="true" into="queryResultParentName">
         <Where>
           <Eq param="queryResultParent" property="{$cvirbindings/@p1}"/>
         </Where>
       </GetData>
        
       <UseDoc code="queryResultParentName">
         <GetDoc code="queryResultParentName" into="queryResultParentConcept" name="{../../../Concept/@name}"/>
       </UseDoc>
       <UseDoc code="queryResultParentConcept">
         <GetAttr name="name" into="parentName"/>
       </UseDoc>
	
       <Eval type="number" default="$counter + 1" target="position"/>
	
       <UseDoc code="Parent">
         <AddAttr name="id" src="queryResultParent"/>
         <AddAttr name="name" src="parentName"/>
         <AddAttr name="pos" src="position"/>
       </UseDoc>

       
       <UseDoc code="Parents">
         <AddDoc src="Parent"/>
       </UseDoc> 	
       
       <Call dataport="getAncestors{@id_cvincludeparent}_{@id_cvinclude}" into="parentRoot">
         <SendParam code="{$cvirbindings/@p1}" source="queryResultParent"/>
         <SendParam code="counter" source="position"/>
       </Call>
       
        <ForEach elem="Parent" in="parentRoot" as="Parent" context="no">
          <UseDoc code="Parents">
            <AddDoc src="Parent"/>
          </UseDoc>
        </ForEach>
        
     </If>

     </Process>
     
     <OutData type="xml">
       <Output source="Parents"/>
     </OutData>
     </Dataport>
   </xsl:if>
<!-- UPDATE END (Juraj Obert): Inheritance support -->   

    <Dataport code="print{@id_cvinclude}">
      <InData>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p1}"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
        <InParam code="{@concept}.orderby" optional="yes"/>
        <InParam code="{@concept}.order" optional="yes"/>
        <InParam code="{@concept}.filterfirst" default="{@filterfirst}" optional="yes"/>
        <InDoc doctype="DPFilter" code="{@concept}.filter" optional="yes"/>
        <InParam code="setfilter" optional="yes"/>
        <InParam code="select" default="no"/>
        <InParam code="style" default="1" optional="yes"/>
      </InData>
      <Process>
        <SessionStore code="select" src="select" scope="dp"/>
        <SessionStore code="{@concept}.filterfirst" src="{@concept}.filterfirst" scope="dp"/>
        <SessionStore code="style" src="style" scope="dp"/>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <SessionStore code="{@p1}" src="{@p1}" scope="dp"/>
          <SessionStore code="{@p1}" src="{@p1}" scope="friend" friend="updatelist{$id_cvinclude}"/>
        </xsl:for-each>
        <xsl:variable name="propprefix">
          <xsl:choose>
            <xsl:when test="@treelist='1' and name(..)='CView'">/<xsl:value-of select="@concept"/>/</xsl:when>
            <xsl:otherwise></xsl:otherwise>
          </xsl:choose>
        </xsl:variable>

        <Copy target="nofilter" default="no"/>

        <If code="{@concept}.filter" contains="">
          <Copy target="nofilter" default="yes"/>
          <xsl:if test="count(CVIProperties/CVIProperty[@onfilter='show' and DefaultFilter and DefaultFilter!=''])>0">
            <CreateDoc code="{@concept}.filter" doctype="DPFilter"/>
            <xsl:for-each select="CVIProperties/CVIProperty[@onfilter='show' and DefaultFilter and DefaultFilter!='']">
              <xsl:choose>
                <xsl:when test="not(RefProp) or (@ref!='' and @fetchtype='direct')">
                  <xsl:choose>
                    <xsl:when test="@type='int' or @type='float' or @type='boolean' or @type='boolean_txt'">
                          <CreateDoc code="x" doctype="Eq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                    </xsl:when>
                    <xsl:when test="@type='date' or @type='datetime' or @type='timestamp'">
                          <CreateDoc code="x" doctype="GtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_from"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                          <CreateDoc code="x" doctype="LtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_to"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                    </xsl:when>
                    <xsl:otherwise>
                          <CreateDoc code="x" doctype="Like"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" default="{DefaultFilter}"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:when>
              </xsl:choose>
            </xsl:for-each>
          </xsl:if>
        </If>

        <If code="setfilter" contains="yes">
          <Copy target="nofilter" default="no"/>
          <IfNot code="{@concept}.noinit" contains="yes">
            <Copy target="{@concept}.start" default="1"/>
          </IfNot>
          <CreateDoc code="{@concept}.filter" doctype="DPFilter"/>
          <xsl:for-each select="CVIProperties/CVIProperty[@onfilter='show']">
            <xsl:choose>
              <xsl:when test="not(RefProp) or (@ref!='' and @fetchtype='direct')">
                <xsl:choose>
                  <xsl:when test="@type='int' or @type='float' or @type='boolean' or @type='boolean_txt'">
                      <IfNot code="{@formcode}" contains="">
                        <If code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="IsNull"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                          </UseDoc>
                        </If>
                        <IfNot code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="Eq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" src="{@formcode}"/>
                          </UseDoc>
                        </IfNot>
                        <UseDoc code="{../../@concept}.filter">
                          <AddDoc src="x"/>
                        </UseDoc>
                      </IfNot>
                  </xsl:when>
                  <xsl:when test="@type='date' or @type='datetime' or @type='timestamp'">
                      <If code="{@formcode}_from" contains="!">
                        <CreateDoc code="x" doctype="IsNull"/>
                        <UseDoc code="x">
                          <AddAttr name="property" default="{$propprefix}{@name}"/>
                          <AddAttr name="nick" default="{$propprefix}{@name}_from"/>
                        </UseDoc>
                        <UseDoc code="{../../@concept}.filter">
                          <AddDoc src="x"/>
                        </UseDoc>
                      </If>
                      <IfNot code="{@formcode}_from" contains="!">
                        <IfNot code="{@formcode}_from" contains="">
                          <CreateDoc code="x" doctype="GtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_from"/>
                            <AddAttr name="default" src="{@formcode}_from"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                        </IfNot>
                        <IfNot code="{@formcode}_to" contains="">
                          <CreateDoc code="x" doctype="LtEq"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="nick" default="{$propprefix}{@name}_to"/>
                            <AddAttr name="default" src="{@formcode}_to"/>
                          </UseDoc>
                          <UseDoc code="{../../@concept}.filter">
                            <AddDoc src="x"/>
                          </UseDoc>
                        </IfNot>
                      </IfNot>
                  </xsl:when>
                  <xsl:otherwise>
                      <IfNot code="{@formcode}" contains="">
                        <If code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="IsNull"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                          </UseDoc>
                        </If>
                        <IfNot code="{@formcode}" contains="!">
                          <CreateDoc code="x" doctype="Like"/>
                          <UseDoc code="x">
                            <AddAttr name="property" default="{$propprefix}{@name}"/>
                            <AddAttr name="default" src="{@formcode}"/>
                          </UseDoc>
                        </IfNot>
                        <UseDoc code="{../../@concept}.filter">
                          <AddDoc src="x"/>
                        </UseDoc>
                      </IfNot>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:when>
              <xsl:otherwise>
                <xsl:for-each select="RefProp">
                  <IfNot code="{@formcode}" contains="">
                    <If code="{@formcode}" contains="!">
                      <CreateDoc code="x" doctype="IsNull"/>
                      <UseDoc code="x">
                        <AddAttr name="property" default="{../@nickname}.{@refconcept}/{@code}"/>
                      </UseDoc>
                    </If>
                    <IfNot code="{@formcode}" contains="!">
                    <xsl:choose>
                      <xsl:when test="@type='int' or @type='float' or @type='date' or @type='datetime' or @type='timestamp' or @type='boolean' or @type='boolean_txt'">
                        <CreateDoc code="x" doctype="Eq"/>
                        <UseDoc code="x">
                          <AddAttr name="property" default="{../@nickname}.{@refconcept}/{@code}"/>
                          <AddAttr name="default" src="{@formcode}"/>
                        </UseDoc>
                      </xsl:when>
                      <xsl:otherwise>
                        <CreateDoc code="x" doctype="Like"/>
                        <UseDoc code="x">
                          <AddAttr name="property" default="{../@nickname}.{@refconcept}/{@code}"/>
                          <AddAttr name="default" src="{@formcode}"/>
                        </UseDoc>
                      </xsl:otherwise>
                    </xsl:choose>
                    </IfNot>
                    <UseDoc code="{../../../@concept}.filter">
                      <AddDoc src="x"/>
                    </UseDoc>
                  </IfNot>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:for-each>
        </If>

        <Call dataport="{@concept}{@id_cvinclude}_PRINT" into="{@concept}{@id_cvinclude}_PRINT">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <SendParam code="{@p2}" source="{@p1}"/>
          </xsl:for-each>
          <SendParam code="{@concept}.orderby" optional="yes"/>
          <SendParam code="{@concept}.order" optional="yes"/>
          <SendParam code="{@concept}.filter" optional="yes"/>
          <SendParam code="{@concept}.filterfirst" optional="yes"/>
          <SendParam code="select" default="no"/>
        </Call>

        <CreateDoc code="navig" doctype="DPNavig"/>

        <xsl:for-each select="ancestor::CVInclude">
          <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
            <xsl:for-each select="$cvirbindings">
              <SendParam code="{@p1}"/>
            </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
          </Call>
          <UseDoc code="navig">
            <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
          </UseDoc>
        </xsl:for-each>

        <UseDoc code="{@concept}{@id_cvinclude}_PRINT">
          <AddAttr name="style" src="style"/>
        </UseDoc>

        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='print'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='print' and position()&gt;1]">
            <If code="style">
              <xsl:attribute name="contains"><xsl:value-of select="position()+1"/></xsl:attribute>
              <DoOutput>
                <xsl:attribute name="ref">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              </DoOutput>
            </If>
          </xsl:for-each>
        </xsl:if>

      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}{@id_cvinclude}_PRINT"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="{$ro_redir}print{@id_cvinclude}.xsl" hrefparam="ssnstlprn" hrefsuffix="{@id_cvinclude}.xsl"/>
        </Output>
        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='print'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='print' and position()&gt;1]">
            <Output>
              <xsl:attribute name="id">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              <OutDoc source="{../../@concept}{../../@id_cvinclude}_PRINT"/>
              <OutDoc source="navig" optional="yes"/>
              <Template href="/header.xsl"/>
              <Template hrefparam="ssnstlprn">
                <xsl:attribute name="href">print<xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
                <xsl:attribute name="hrefsuffix"><xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
              </Template>
            </Output>
          </xsl:for-each>
        </xsl:if>
      </OutData>
    </Dataport>

    <Dataport code="{@concept}{@id_cvinclude}_PRINT">
      <InData>
        <InParam code="{@concept}.step" optional="yes" default="1000000"/>
        <InParam code="{@concept}.start" optional="yes" default="1"/>
        <InParam code="{@concept}.orderby" default="{$deforderby}" optional="yes"/>
        <InParam code="{@concept}.order" default="{$deforder}" optional="yes"/>
        <InParam code="{@concept}.filterfirst" default="{@filterfirst}" optional="yes"/>
        <InParam code="select" default="no"/>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p2}"/>
        </xsl:for-each>
        <InDoc doctype="DPFilter" code="{@concept}.filter" optional="yes"/>
      </InData>
      <Process>
        <SessionStore code="{@concept}.orderby" src="{@concept}.orderby" scope="dp"/>
        <SessionStore code="{@concept}.order" src="{@concept}.order" scope="dp"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="dp"/>
        <SessionStore code="{@concept}.orderby" src="{@concept}.orderby" scope="friend" friend="{@concept}{@id_cvinclude}_EXPLIST"/>
        <SessionStore code="{@concept}.order" src="{@concept}.order" scope="friend" friend="{@concept}{@id_cvinclude}_EXPLIST"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="friend" friend="{@concept}{@id_cvinclude}_EXPLIST"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="friend" friend="print{@id_cvinclude}"/>

        <IfNot code="{@concept}.filterfirst" contains="1">
        <xsl:choose>
          <xsl:when test="@treelist='1' and name(..)='CView'">
          <GetData conceptview="{ancestor::CView/@name}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist">
            <Where>
              <xsl:if test="name(..)!='CView'">
                <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                  <Eq property="{@p2}" param="{@p2}"/>
                </xsl:for-each>
              </xsl:if>
            </Where>
          </GetData>
          </xsl:when>
          <xsl:otherwise>
          <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter" show="onlist">
            <Where>
              <xsl:if test="name(..)!='CView'">
                <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                  <Eq property="{@p2}" param="{@p2}"/>
                </xsl:for-each>
              </xsl:if>
            </Where>
          </GetData>
          </xsl:otherwise>
        </xsl:choose>
        </IfNot>

        <EnsureDoc code="{@concept}.filter" doctype="DPFilter"/>
        <CreateDoc code="res" doctype="DPPrint"/>
        <UseDoc code="res">
          <AddDoc src="{@concept}.filter"/>
          <AddDoc src="{@concept}"/>
          <AddDoc src="{@concept}.dppage"/>
          <AddAttr name="order" src="{@concept}.order"/>
          <AddAttr name="orderby" src="{@concept}.orderby"/>
          <AddAttr name="name" default="{@concept}"/>
          <AddAttr name="selectfun" src="select"/>
          <AddAttr name="filterfirst" src="{@concept}.filterfirst"/>
        </UseDoc>

        <xsl:if test="CVIProperties/CVIProperty[(@onfilter='show' or (@onedit='show' and @onlist='show')) and @ref and @ref!='' and @fetchtype='direct']">
          <CreateDoc code="opts" doctype="Opts"/>

        <xsl:for-each select="CVIProperties/CVIProperty[(@onfilter='show' or (@onedit='show' and @onlist='show')) and @ref and @ref!='' and @fetchtype='direct' and (not(@extwork) or @extwork='')]">
          <xsl:variable name="attr">
            <xsl:choose>
              <xsl:when test="@attr='1'">true</xsl:when>
              <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="RefProp">
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                <Properties>
                  <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                  <xsl:for-each select="RefProp">
                    <xsl:variable name="rattr">
                      <xsl:choose>
                        <xsl:when test="@attr='1'">true</xsl:when>
                        <xsl:otherwise>false</xsl:otherwise>
                      </xsl:choose>
                    </xsl:variable>
                    <Property name="{@refconcept}/{@code}" attr="{$rattr}"/>
                  </xsl:for-each>
                </Properties>
                <Orders>
                  <OrderBy type="asc"><Property name="{@refconcept}/{RefProp[1]/@code}"/></OrderBy>
                </Orders>
              </GetData>
            </xsl:when>
            <xsl:otherwise>
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                <Properties>
                  <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                </Properties>
                <Orders>
                  <OrderBy type="asc"><Property name="{@refconcept}/{@refprop}"/></OrderBy>
                </Orders>
              </GetData>
            </xsl:otherwise>
          </xsl:choose>

          <UseDoc code="opts">
            <AddDoc src="XXR_{@refconcept}"/>
          </UseDoc>

        </xsl:for-each>

        <xsl:for-each select="CVIProperties/CVIProperty[(@onfilter='show' or (@onedit='show' and @onlist='show')) and @ref and @ref!='' and @fetchtype='direct' and @extwork and @extwork!='']">

          <GetData conceptview="{@extwork}" into="XXR_{@refconcept}" path="/" rights="true" show="onlist" allkeys="true"/>

          <UseDoc code="opts">
            <AddDoc src="XXR_{@refconcept}"/>
          </UseDoc>

        </xsl:for-each>

        <UseDoc code="res">
          <AddDoc src="opts"/>
        </UseDoc>
        </xsl:if>

      </Process>
      <OutData type="xml">
        <Output source="res"/>
      </OutData>
    </Dataport>


    <Dataport code="{@concept}{@id_cvinclude}_EXPLIST">
      <InData>
        <InParam code="{@concept}.step" default="{$pagelen}"/>
        <InParam code="{@concept}.start" optional="yes"/>
        <InParam code="{@concept}.orderby" default="{$deforderby}" optional="yes"/>
        <InParam code="{@concept}.order" default="{$deforder}" optional="yes"/>
        <InParam code="select" default="no"/>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p2}"/>
        </xsl:for-each>
        <InDoc doctype="DPFilter" code="{@concept}.filter" optional="yes"/>
      </InData>
      <Process>
        <SessionStore code="{@concept}.orderby" src="{@concept}.orderby" scope="dp"/>
        <SessionStore code="{@concept}.order" src="{@concept}.order" scope="dp"/>
        <SessionStore code="{@concept}.filter" src="{@concept}.filter" scope="dp"/>

        <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="{@concept}" distinct="{$isdistinct}" cond="{@concept}.filter">
          <Where>
            <xsl:if test="name(..)!='CView'">
              <xsl:for-each select="../CVIRBindings[../@cardinality='1:n']/CVIRBinding">
                <Eq property="{@p2}" param="{@p2}"/>
              </xsl:for-each>
            </xsl:if>
          </Where>
        </GetData>

        <EnsureDoc code="{@concept}.filter" doctype="DPFilter"/>
        <CreateDoc code="res" doctype="DPList"/>
        <UseDoc code="res">
          <AddDoc src="{@concept}.filter"/>
          <AddDoc src="{@concept}"/>
          <AddDoc src="{@concept}.dppage"/>
          <AddAttr name="order" src="{@concept}.order"/>
          <AddAttr name="orderby" src="{@concept}.orderby"/>
          <AddAttr name="name" default="{@concept}"/>
          <AddAttr name="selectfun" src="select"/>
        </UseDoc>

      </Process>
      <OutData type="xml">
        <Output source="res"/>
      </OutData>
    </Dataport>


    <xsl:if test="name(..)='CView'">  <!-- this is initial edit jump (for external reference to some detail) -->
      <Dataport code="edit">
        <InData>
          <xsl:for-each select="Keys/Binding">
            <InParam code="{@property}"/>
          </xsl:for-each>
        </InData>
        <Process>
        </Process>
        <OutData type="html">
          <ChangeState dataport="edit{@id_cvinclude}" external="yes">
            <xsl:for-each select="Keys/Binding">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:for-each>
          </ChangeState>
        </OutData>
      </Dataport>
      <Dataport code="editanonkey">
        <InData>
          <xsl:for-each select="Keys/Binding">
            <InParam code="key"/>
          </xsl:for-each>
        </InData>
        <Process>
        </Process>
        <OutData type="html">
          <ChangeState dataport="edit{@id_cvinclude}" external="yes">
            <xsl:for-each select="Keys/Binding">
              <OutParam code="{@property}" source="key"/>
            </xsl:for-each>
          </ChangeState>
        </OutData>
      </Dataport>
    </xsl:if>


    <Dataport code="edit{@id_cvinclude}">
      <InData>
        <xsl:for-each select="Keys/Binding">
          <InParam code="{@property}"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
        <InParam code="style" default="1" optional="yes"/>
      </InData>
      <Process>
        <SessionStore code="style" src="style" scope="dp"/>
        <xsl:for-each select="Keys/Binding">
          <SessionStore code="{@property}" src="{@property}" scope="dp"/>
        </xsl:for-each>
        <Call dataport="{@concept}{@id_cvinclude}_EDIT" into="{@concept}_EDIT">
          <xsl:for-each select="Keys/Binding">
            <SendParam code="{@property}"/>
          </xsl:for-each>
        </Call>

        <xsl:if test="Catalog">
            <!-- get data for cat -->
            <Call dataport="{@concept}_CAT" into="{@concept}_CAT">
              <xsl:for-each select="Keys/Binding">
                <SendParam code="{@property}"/>
                <SendParam code="{@concept}.orderby" optional="yes"/>
                <SendParam code="{@concept}.order" optional="yes"/>
              </xsl:for-each>
            </Call>
        </xsl:if>

        <CreateDoc code="navig" doctype="DPNavig"/>

        <xsl:for-each select="ancestor::CVInclude">
          <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
            <xsl:for-each select="$cvirbindings">
              <SendParam code="{@p1}" source="{@p2}"/>
            </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
          </Call>
          <UseDoc code="navig">
            <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
          </UseDoc>
        </xsl:for-each>

        <UseDoc code="{@concept}_EDIT">
          <AddAttr name="style" src="style"/>
        </UseDoc>

        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='form'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='form' and position()&gt;1]">
            <If code="style">
              <xsl:attribute name="contains"><xsl:value-of select="position()+1"/></xsl:attribute>
              <DoOutput>
                <xsl:attribute name="ref">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              </DoOutput>
            </If>
          </xsl:for-each>
        </xsl:if>

      </Process>
      <OutData type="html">
        <Output>
          <xsl:if test="Catalog">
            <OutDoc source="{@concept}_CAT"/>
          </xsl:if>
          <OutDoc source="{@concept}_EDIT"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="form{@id_cvinclude}.xsl" hrefparam="ssnstledt" hrefsuffix="{@id_cvinclude}.xsl"/>
          <Template href="{$ro_redir}flape{@id_cvinclude}.xsl"/>
        </Output>
        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='form'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='form' and position()&gt;1]">
            <Output>
              <xsl:attribute name="id">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              <xsl:if test="Catalog">
                <OutDoc source="{../../@concept}_CAT"/>
              </xsl:if>
              <OutDoc source="{../../@concept}_EDIT"/>
              <OutDoc source="navig" optional="yes"/>
              <Template href="/header.xsl"/>
              <Template hrefparam="ssnstledt">
                <xsl:attribute name="href">form<xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
                <xsl:attribute name="hrefsuffix"><xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
              </Template>
              <Template href="{$ro_redir}flape{../../@id_cvinclude}.xsl"/>
            </Output>
          </xsl:for-each>
        </xsl:if>
      </OutData>
    </Dataport>


    <Dataport code="{@concept}{@id_cvinclude}_EDIT">
      <InData>
        <xsl:for-each select="Keys/Binding">
          <InParam code="{@property}"/>
        </xsl:for-each>
        <InParam code="norec" default="no"/>
      </InData>
      <Process>
       <CreateDoc code="res" doctype="DPEdit"/>
       <xsl:for-each select="Keys/Binding">
         <If code="{@property}" contains="">
           <DoOutput ref="done"/>
         </If>
       </xsl:for-each>

       <xsl:choose>
       <xsl:when test="@update='1' and $readonly='0'">

        <If code="norec" contains="no">        
          <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" show="onedit" allkeys="true">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="{@property}" param="{@property}"/>
              </xsl:for-each>
              <xsl:if test="name(..)='CView'">
                <xsl:if test="@xxxrecursive='yes'">
                  <Eq property="xxxisroot" default="1"/>
                </xsl:if>
              </xsl:if>
            </Where>
          </GetData>
        </If>
        <If code="norec" contains="yes">        
          <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" show="onedit" allkeys="true">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="{@property}" param="{@property}"/>
              </xsl:for-each>
            </Where>
          </GetData>
        </If>

        </xsl:when>
        <xsl:otherwise>

        <If code="norec" contains="no">        
          <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" show="ondetail">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="{@property}" param="{@property}"/>
              </xsl:for-each>
              <xsl:if test="name(..)='CView'">
                <xsl:if test="@xxxrecursive='yes'">
                  <Eq property="xxxisroot" default="1"/>
                </xsl:if>
              </xsl:if>
            </Where>
          </GetData>
        </If>
        <If code="norec" contains="yes">        
          <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" show="ondetail">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="{@property}" param="{@property}"/>
              </xsl:for-each>
            </Where>
          </GetData>
        </If>

        </xsl:otherwise>
        </xsl:choose>

        <UseDoc code="res">
          <AddDoc src="XXC_{@concept}"/>
        </UseDoc>

        <xsl:if test="@update='1' and $readonly='0'">

          <CreateDoc code="opts" doctype="Opts"/>

        <!-- get data for form: do direct fetch lists -->
        <xsl:for-each select="CVIProperties/CVIProperty[PropGroup/@update='1' and (@fetchtype='direct' and @ref and @ref!='' and (not(@extwork) or @extwork='') and @onedit='show')]">
          <xsl:variable name="attr">
            <xsl:choose>
              <xsl:when test="@attr='1'">true</xsl:when>
              <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="RefProp">
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                <Properties>
                  <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                  <xsl:for-each select="RefProp">
                    <xsl:variable name="rattr">
                      <xsl:choose>
                        <xsl:when test="@attr='1'">true</xsl:when>
                        <xsl:otherwise>false</xsl:otherwise>
                      </xsl:choose>
                    </xsl:variable>
                    <Property name="{@refconcept}/{@code}" attr="{$rattr}"/>
                  </xsl:for-each>
                </Properties>
                <Orders>
                  <OrderBy type="asc"><Property name="{@refconcept}/{RefProp[1]/@code}"/></OrderBy>
                </Orders>
              </GetData>
            </xsl:when>
            <xsl:otherwise>
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                 <Properties>
                   <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                 </Properties>
                 <Orders>
                   <OrderBy type="asc"><Property name="{@refconcept}/{@refprop}"/></OrderBy>
                 </Orders>
               </GetData>
             </xsl:otherwise>
           </xsl:choose>

           <UseDoc code="opts">
             <AddDoc src="XXR_{@refconcept}"/>
           </UseDoc>

        </xsl:for-each>

        <xsl:for-each select="CVIProperties/CVIProperty[PropGroup/@update='1' and (@fetchtype='direct' and @ref and @ref!='' and @extwork and @extwork!='' and @onedit='show')]">
          <GetData conceptview="{@extwork}" into="XXR_{@refconcept}" path="/" rights="true" show="onlist" allkeys="true"/>

          <UseDoc code="opts">
            <AddDoc src="XXR_{@refconcept}"/>
          </UseDoc>

        </xsl:for-each>

          <UseDoc code="res">
            <AddDoc src="opts"/>
          </UseDoc>

        </xsl:if>

      </Process>
      <OutData type="xml">
        <Output id="done" source="res"/>
      </OutData>
    </Dataport>




    <xsl:if test="@update='1' and $readonly='0'">
    <Dataport code="update{@id_cvinclude}">
      <InData>
        <xsl:for-each select="Schedules/UpdateSchedule/SchedItem">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <Transaction>
        <xsl:for-each select="Schedules/UpdateSchedule/SchedItem">
          <xsl:if test="KeysIn">
            <xsl:for-each select="KeysIn/Key">
              <xsl:choose>
                <xsl:when test="@attr='1'">
                  <IfNot code="{@param}" contains="">  <!-- TODO: fix gui intermD style instead -->
                    <UseDoc code="{../../@path}">
                      <AddAttr name="{@childprop}" src="{@param}"/>
                    </UseDoc>
                  </IfNot>
                </xsl:when>
                <xsl:otherwise>
                  <IfNot code="{@param}" contains="">  <!-- TODO: fix gui intermD style instead -->
                    <UseDoc code="{../../@path}">
                      <RemoveElem name="{@childprop}"/>
                      <AddElem name="{@childprop}" src="{@param}"/>
                    </UseDoc>
                  </IfNot>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </xsl:if>
          <xsl:choose>
            <xsl:when test="@base='1'">
              <UpdateData concept="{@concept}" with="{@path}" update="yes" insert="no" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
            </xsl:when>
            <xsl:otherwise>
              <UpdateData concept="{@concept}" with="{@path}" update="yes" insert="yes" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:if test="KeysOut">
            <UseDoc code="{@path}">
              <xsl:for-each select="KeysOut/Key">
                <xsl:choose>
                  <xsl:when test="@attr='1'">
                    <GetAttr name="{@parentprop}" into="{@param}"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <GetElem name="{@parentprop}" into="{@param}"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:for-each>
            </UseDoc>
          </xsl:if>
        </xsl:for-each>
        
        <!-- attempt to find and update root of a recursive view -->
        <xsl:if test="name(..)!='CView' and ancestor::CView/CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']">
          <UseDoc code="{@concept}">
            <GetAttr into="child" name="{ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding/@p2}"/>
          </UseDoc>
          <Call dataport="updrecroot" into="updrecrootres">
             <SendParam code="child" source="child"/>
          </Call>
        </xsl:if>
        
        </Transaction>

        <UseDoc code="{@nickname}">
          <xsl:for-each select="Keys/Binding">
            <GetAttr name="{@property}" into="XXProp_{@property}"/>
          </xsl:for-each>
        </UseDoc>
      </Process>
      <OutData type="html">
        <xsl:choose>
          <xsl:when test="count(CVIRels/CVIRel/CVInclude[@virtual='0' and (@hasflap='1' or not(@hasflap))])>0">
            <ChangeState dataport="edit{@id_cvinclude}" external="yes">
              <xsl:for-each select="Keys/Binding">
                <OutParam code="{@property}" source="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <OutParam code="{@p1}" source="{@p1}"/>
                </xsl:if>
              </xsl:for-each>
              <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
                <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
                <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
                  <OutParam code="{@property}" source="{@property}"/>
                </xsl:if>
              </xsl:for-each>
            </ChangeState>
          </xsl:when>
          <xsl:otherwise>
            <ChangeState dataport="list{@id_cvinclude}" external="yes">
              <xsl:for-each select="Keys/Binding">
                <OutParam code="{@property}" source="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <OutParam code="{@p1}" source="{@p1}"/>
                </xsl:if>
              </xsl:for-each>
              <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
                <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
                <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
                  <OutParam code="{@property}" source="{@property}"/>
                </xsl:if>
              </xsl:for-each>
            </ChangeState>
          </xsl:otherwise>
        </xsl:choose>
      </OutData>
    </Dataport>

    <Dataport code="updatelist{@id_cvinclude}">
      <InData>
        <InDoc code="{@nickname}" doctype="{@conceptcoll}" nickname="{@nickname}"/>
        <xsl:for-each select="Schedules/UpdateSchedule/SchedItem[@base='0']">
          <InDoc code="{@nickname}" doctype="{@concept}s" nickname="{@nickname}"/>
        </xsl:for-each>
        <xsl:for-each select="../../../Keys/Binding"> <!-- is this needed? -->
          <InParam code="XXProp_{@property}" optional="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <Transaction>
          <UpdateData concept="{@concept}" with="{@nickname}" update="yes" insert="no" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
          <xsl:for-each select="Schedules/UpdateSchedule/SchedItem[@base='0']">
            <UpdateData concept="{@concept}" with="{@nickname}" update="yes" insert="no" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
          </xsl:for-each>
        </Transaction>
      </Process>
      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes">
          <xsl:for-each select="../../../Keys/Binding">
            <OutParam code="{@property}" source="XXProp_{@property}" optional="yes"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>

    </xsl:if>



    <Dataport code="{@concept}{@id_cvinclude}_{@id_cvinclude}_KEYS_LBLS">
      <InData>
        <xsl:for-each select="Keys/Binding">
          <InParam code="{@property}"/>
        </xsl:for-each>
      </InData>
      <Process>
        <GetData coll="{@conceptcoll}" into="res" path="{@rootnickpath}" conceptview="{ancestor::CView/@name}" rights="true" show="onlabel" allkeys="true">
          <Where>
            <xsl:for-each select="Keys/Binding">
              <Eq property="{@property}" param="{@property}"/>
            </xsl:for-each>
          </Where>
        </GetData>
        <xsl:if test="@xxxrecursive='yes'">
          <GetData coll="{@conceptcoll}" conceptview="{ancestor::CView/@name}" into="resrec" path="{CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@id_concept=current()/@id_concept]/@rootnickpath}" rights="true" show="onlabel" allkeys="true">
            <Where>              
              <xsl:for-each select="CVIRels/CVIRel/CVInclude/CVIRels/CVIRel[CVInclude/@id_concept=current()/@id_concept]/CVIRBindings/CVIRBinding">
                <Eq property="{@p1}" param="{@p2}"/>
              </xsl:for-each>
            </Where>
          </GetData>
          <UseDoc code="res">
            <AddDoc src="resrec"/>
          </UseDoc>
        </xsl:if>
      </Process>
      <OutData type="xml">
        <Output source="res"/>
      </OutData>
    </Dataport>

    <xsl:for-each select="ancestor::CVInclude">
      <Dataport code="{@concept}{$id_cvinclude}_{@id_cvinclude}_KEYS_LBLS">
        <InData>
          <xsl:for-each select="$this_cvinclude/Keys/Binding">
            <InParam code="{@property}" optional="yes"/>
          </xsl:for-each>
          <xsl:variable name="xcvi" select="@id_cvinclude"/>
          <xsl:for-each select="CVIRels/CVIRel/CVIRBindings/CVIRBinding">
            <xsl:if test="count(../..//CVInclude[@id_cvinclude=$id_cvinclude])=1">
              <xsl:variable name="xp2" select="@p2"/>
              <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                <InParam code="{@p2}"/>
              </xsl:if>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="Keys/Binding">
            <InParam code="{@property}" optional="yes"/>
          </xsl:for-each>
        </InData>
        <Process>
            <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="res">
              <xsl:variable name="xkeys" select="Keys/Binding"/>
              <xsl:for-each select="$cvirbindings">
                <xsl:variable name="xp1" select="@p1"/>
                <xsl:if test="$xkeys[@property=$xp1]">
                  <SendParam code="{@p1}" source="{@p2}"/>
                </xsl:if>
              </xsl:for-each>
              <xsl:variable name="xcvi" select="@id_cvinclude"/>
              <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
                <xsl:for-each select="CVIRels/CVIRel/CVIRBindings/CVIRBinding">
                  <xsl:if test="count(../..//CVInclude[@id_cvinclude=$id_cvinclude])=1">
                    <xsl:variable name="xp2" select="@p2"/>
                    <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                      <SendParam code="{@p2}" source="{@p2}"/>
                    </xsl:if>
                  </xsl:if>
                </xsl:for-each>
              </xsl:if>
              <xsl:for-each select="Keys/Binding">
                <SendParam code="{@property}" optional="yes"/>
              </xsl:for-each>
            </Call>
        </Process>
        <OutData type="xml">
          <Output source="res"/>
        </OutData>
      </Dataport>
    </xsl:for-each>


    <xsl:if test="@create='1' and $readonly='0'">

    <Dataport code="create{@id_cvinclude}">
      <InData>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p2}"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
        <InParam code="style" default="1" optional="yes"/>
      </InData>
      <Process>
        <SessionStore code="style" src="style" scope="dp"/>
        <Call dataport="{@concept}{@id_cvinclude}_CREATE" into="{@concept}{@id_cvinclude}_CREATE">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <SendParam code="{@p2}"/>
          </xsl:for-each>
        </Call>
        <CreateDoc code="navig" doctype="DPNavig"/>

        <xsl:for-each select="ancestor::CVInclude">
          <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
            <xsl:for-each select="$cvirbindings">
              <SendParam code="{@p1}" source="{@p2}"/>
            </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
          </Call>
          <UseDoc code="navig">
            <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
          </UseDoc>
        </xsl:for-each>

        <UseDoc code="{@concept}{@id_cvinclude}_CREATE">
          <AddAttr name="style" src="style"/>
        </UseDoc>

        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='create'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='create' and position()&gt;1]">
            <If code="style">
              <xsl:attribute name="contains"><xsl:value-of select="position()+1"/></xsl:attribute>
              <DoOutput>
                <xsl:attribute name="ref">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              </DoOutput>
            </If>
          </xsl:for-each>
        </xsl:if>

      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}{@id_cvinclude}_CREATE"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="create{@id_cvinclude}.xsl" hrefparam="ssnstlcrt" hrefsuffix="{@id_cvinclude}.xsl"/>
          <Template href="flapc{@id_cvinclude}.xsl"/>
        </Output>
        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='create'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='create' and position()&gt;1]">
            <Output>
              <xsl:attribute name="id">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              <OutDoc source="{../../@concept}{../../@id_cvinclude}_CREATE"/>
              <OutDoc source="navig" optional="yes"/>
              <Template href="/header.xsl"/>
              <Template hrefparam="ssnstlcrt">
                <xsl:attribute name="href">create<xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
                <xsl:attribute name="hrefsuffix"><xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
              </Template>
              <Template href="flapc{../../@id_cvinclude}.xsl"/>
            </Output>
          </xsl:for-each>
        </xsl:if>
      </OutData>
    </Dataport>


    <Dataport code="{@concept}{@id_cvinclude}_CREATE">
      <InData>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p2}"/>
        </xsl:for-each>
      </InData>
      <Process>

        <CreateDoc code="{@conceptcoll}" doctype="{@conceptcoll}"/>
        <CreateDoc code="{@concept}" doctype="{@concept}"/>
        <UseDoc code="{@concept}">
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <AddAttr name="{@p2}" src="{@p2}"/>
        </xsl:for-each>
        </UseDoc>
        <UseDoc code="{@conceptcoll}">
          <AddDoc src="{@concept}"/>
        </UseDoc>

        <CreateDoc code="res" doctype="DPEdit"/>
        <UseDoc code="res">
          <AddDoc src="{@conceptcoll}"/>
        </UseDoc>

        <!-- get data for form: do direct fetch lists -->
        <xsl:for-each select="CVIProperties/CVIProperty[PropGroup/@create='1' and (@fetchtype='direct' and @ref and @ref!='' and (not(@extwork) or @extwork='') and @oncreate='show')]">
          <xsl:variable name="attr">
            <xsl:choose>
              <xsl:when test="@attr='1'">true</xsl:when>
              <xsl:otherwise>false</xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="RefProp">
              <GetData name="{@refconcept}" coll="{@refconceptcoll}" into="XXR_{@refconcept}">
                <Properties>
                  <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                  <xsl:for-each select="RefProp">
                    <xsl:variable name="rattr">
                      <xsl:choose>
                        <xsl:when test="@attr='1'">true</xsl:when>
                        <xsl:otherwise>false</xsl:otherwise>
                      </xsl:choose>
                    </xsl:variable>
                    <Property name="{@refconcept}/{@code}" attr="{$rattr}"/>
                  </xsl:for-each>
                </Properties>
                <Orders>
                  <OrderBy type="asc"><Property name="{@refconcept}/{RefProp[1]/@code}"/></OrderBy>
                </Orders>
              </GetData>
            </xsl:when>
            <xsl:otherwise>
              <GetData name="{@refconcept}" coll="{@refconcept}s" into="XXR_{@refconcept}">
                 <Properties>
                   <Property name="{@refconcept}/{@refprop}" attr="{$attr}"/>
                 </Properties>
                 <Orders>
                   <OrderBy type="asc"><Property name="{@refconcept}/{@refprop}"/></OrderBy>
                 </Orders>
               </GetData>
             </xsl:otherwise>
           </xsl:choose>
           <UseDoc code="res">
             <AddDoc src="XXR_{@refconcept}"/>
           </UseDoc>
         </xsl:for-each>

        <xsl:for-each select="CVIProperties/CVIProperty[PropGroup/@create='1' and (@fetchtype='direct' and @ref and @ref!='' and @extwork and @extwork!='' and @oncreate='show')]">
          <GetData conceptview="{@extwork}" into="XXR_{@refconcept}" path="/" rights="true" show="onlist" allkeys="true"/>

          <UseDoc code="res">
            <AddDoc src="XXR_{@refconcept}"/>
          </UseDoc>

        </xsl:for-each>

      </Process>
      <OutData type="xml">
        <Output source="res"/>
      </OutData>
    </Dataport>


    <Dataport code="insert{@id_cvinclude}">
      <InData>
        <InParam code="total" optional="yes" default="1"/>
        <InParam code="groupcreate" optional="yes" default="no"/>
        <xsl:for-each select="Schedules/InsertSchedule/SchedItem">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes" defaults="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <UseDoc code="{@nickname}">
          <xsl:for-each select="Keys/Binding">
            <GetAttr name="{@property}" into="XXProp_{@property}"/>
          </xsl:for-each>
        </UseDoc>
        <Transaction>
        <xsl:for-each select="Schedules/InsertSchedule/SchedItem">
          <xsl:if test="KeysIn">
            <xsl:for-each select="KeysIn/Key">
              <xsl:choose>
                <xsl:when test="@attr='1'">
                  <IfNot code="{@param}" contains=""> <!-- TODO: fix gui intermD style instead -->
                    <UseDoc code="{../../@path}">                    
                      <AddAttr name="{@childprop}" src="{@param}"/>                    
                    </UseDoc>
                  </IfNot>
                </xsl:when>
                <xsl:otherwise>
                  <IfNot code="{@param}" contains=""> <!-- TODO: fix gui intermD style instead -->
                    <UseDoc code="{../../@path}">
                      <RemoveElem name="{@childprop}"/>
                      <AddElem name="{@childprop}" src="{@param}"/>
                    </UseDoc>
                  </IfNot>                  
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>          
          </xsl:if>
          <ObjCall object="{@path}" concept="{@concept}" method="init"/>
          <xsl:choose>
            <xsl:when test="@base='1'">
              <UpdateData concept="{@concept}" with="{@path}" update="no" insert="yes" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}" status="status"/>
            </xsl:when>
            <xsl:otherwise>
              <UpdateData concept="{@concept}" with="{@path}" update="no" insert="yes" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}" status="status"/>
            </xsl:otherwise>
          </xsl:choose>
          <IfNot code="status" contains="inserted">
            <RollbackTransaction/>
            <DoOutput ref="failed"/>
          </IfNot>
          <xsl:if test="KeysOut">
          <UseDoc code="{@path}">
            <xsl:for-each select="KeysOut/Key">
              <xsl:choose>
                <xsl:when test="@attr='1'">
                  <GetAttr name="{@parentprop}" into="{@param}"/>
                </xsl:when>
                <xsl:otherwise>
                  <GetElem name="{@parentprop}" into="{@param}"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </UseDoc>
          </xsl:if>
        </xsl:for-each>

        <!-- attempt to find and update root of a recursive view -->
        <xsl:if test="name(..)!='CView' and ancestor::CView/CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']">
          <UseDoc code="{@concept}">
            <GetAttr into="child" name="{ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding/@p2}"/>
          </UseDoc>
          <Call dataport="updrecroot" into="updrecrootres">
             <SendParam code="child" source="child"/>
          </Call>
        </xsl:if>
        </Transaction>

        <Eval type="number" target="total" default="$total-1"/>
        <IfNot code="total" contains="0.0">
          <DoOutput ref="insertnext"/>
        </IfNot>

        <UseDoc code="{@nickname}">
          <xsl:for-each select="Keys/Binding">
            <GetAttr name="{@property}" into="XXProp_{@property}"/>
          </xsl:for-each>
        </UseDoc>

        <xsl:if test="count(CVIRels/CVIRel/CVInclude[@virtual='0' and (@hasflap='1' or not(@hasflap))])>0">
          <If code="groupcreate" contains="yes">
            <DoOutput ref="forcelist"/>
          </If>
        </xsl:if>

      </Process>
      <OutData type="html">
        <xsl:choose>
          <xsl:when test="count(CVIRels/CVIRel/CVInclude[@virtual='0' and (@hasflap='1' or not(@hasflap))])>0">
            <ChangeState dataport="edit{@id_cvinclude}" external="yes">
              <xsl:for-each select="Keys/Binding">
                <OutParam code="{@property}" source="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <OutParam code="{@p1}" source="{@p1}"/>
                </xsl:if>
              </xsl:for-each>
              <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
                <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
                <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
                  <OutParam code="{@property}" source="{@property}"/>
                </xsl:if>
              </xsl:for-each>
            </ChangeState>
            <ChangeState id="forcelist" dataport="list{@id_cvinclude}" external="yes">
              <xsl:for-each select="Keys/Binding">
                <OutParam code="{@property}" source="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <OutParam code="{@p1}" source="{@p1}"/>
                </xsl:if>
              </xsl:for-each>
              <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
                <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
                <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
                  <OutParam code="{@property}" source="{@property}"/>
                </xsl:if>
              </xsl:for-each>
            </ChangeState>
          </xsl:when>
          <xsl:otherwise>
            <ChangeState dataport="list{@id_cvinclude}" external="yes">
              <xsl:for-each select="Keys/Binding">
                <OutParam code="{@property}" source="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <OutParam code="{@p1}" source="{@p1}"/>
                </xsl:if>
              </xsl:for-each>
              <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
                <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
                <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
                  <OutParam code="{@property}" source="{@property}"/>
                </xsl:if>
              </xsl:for-each>
            </ChangeState>
          </xsl:otherwise>
        </xsl:choose>
        <ChangeState id="failed" dataport="insertfailed{@id_cvinclude}" external="yes">
          <xsl:for-each select="Keys/Binding">
            <OutParam code="{@property}" source="XXProp_{@property}" optional="yes"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <ChangeState id="insertnext" dataport="insert{@id_cvinclude}" external="yes">
          <OutParam code="total" source="total"/>
          <OutParam code="groupcreate" source=" " default="yes"/>
          <xsl:for-each select="CVIProperties/CVIProperty">
            <OutParam code="{@formcode}" optional="yes"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>

    <xsl:if test="@insertcoll='1' or boolean(CVIProperties/CVIProperty[@fetchtype='external' and @extwork!='' and (not(@allowmulti) or @allowmulti!='0')])">
    <Dataport code="insertcoll{@id_cvinclude}">
      <InData>
        <xsl:for-each select="Schedules/InsertSchedule/SchedItem">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes" defaults="yes"/>
        </xsl:for-each>
        <xsl:for-each select="Schedules/InsertSchedule/SchedItem">
          <InDoc code="{@path}s" doctype="{@concept}s" nickname="{@path}s" concept="no"/>
        </xsl:for-each>
        <InParam code="collsize" optional="no"/>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>

      <Process>
        <UseDoc code="{@nickname}">
          <xsl:for-each select="Keys/Binding">
            <GetAttr name="{@property}" into="XXProp_{@property}"/>
          </xsl:for-each>
        </UseDoc>
        <Transaction>
          <xsl:for-each select="Schedules/InsertSchedule/SchedItem">
            <ForEach elem="{@concept}" in="{@path}s" as="{@path}">
              <xsl:if test="KeysIn">
              <UseDoc code="{@path}">
                <xsl:for-each select="KeysIn/Key">
                  <xsl:choose>
                    <xsl:when test="@attr='1'">
                      <AddAttr name="{@childprop}" src="{@param}"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <RemoveElem name="{@childprop}"/>
                      <AddElem name="{@childprop}" src="{@param}"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:for-each>
              </UseDoc>
              </xsl:if>
              <ObjCall object="{@path}" concept="{@concept}" method="init"/>
              <xsl:choose>
                <xsl:when test="@base='1'">
                  <UpdateData concept="{@concept}" with="{@path}" update="no" insert="yes" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}" status="status"/>
                </xsl:when>
                <xsl:otherwise>
                  <UpdateData concept="{@concept}" with="{@path}" update="no" insert="yes" rights="true" work="{ancestor::CView/@name}" workpath="{@rootnickpath}" status="status"/>
                </xsl:otherwise>
              </xsl:choose>
              <IfNot code="status" contains="inserted">
                <RollbackTransaction/>
                <DoOutput ref="failed"/>
              </IfNot>
              <xsl:if test="KeysOut">
              <UseDoc code="{@path}">
                <xsl:for-each select="KeysOut/Key">
                  <xsl:choose>
                    <xsl:when test="@attr='1'">
                      <GetAttr name="{@parentprop}" into="{@param}"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <GetElem name="{@parentprop}" into="{@param}"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:for-each>
              </UseDoc>
              </xsl:if>
              <UseDoc code="{@nickname}">
                <xsl:for-each select="../../../Keys/Binding">
                  <GetAttr name="{@property}" into="XXProp_{@property}"/>
                </xsl:for-each>
              </UseDoc>
            </ForEach>
          </xsl:for-each>
        </Transaction>
        <xsl:if test="count(CVIRels/CVIRel/CVInclude[@virtual='0' and (@hasflap='1' or not(@hasflap))])>0">
          <If code="collsize" contains="1">
            <DoOutput ref="edit"/>
          </If>
        </xsl:if>
      </Process>

      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes">
          <xsl:for-each select="Keys/Binding">
            <OutParam code="{@property}" source="XXProp_{@property}" optional="yes"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <xsl:if test="count(CVIRels/CVIRel/CVInclude[@virtual='0' and (@hasflap='1' or not(@hasflap))])>0">
          <ChangeState id="edit" dataport="edit{@id_cvinclude}" external="yes">
            <xsl:for-each select="Keys/Binding">
              <OutParam code="{@property}" source="XXProp_{@property}"/>
            </xsl:for-each>
            <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
              <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                <OutParam code="{@p1}" source="{@p1}"/>
              </xsl:if>
            </xsl:for-each>
            <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
              <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
              <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
                <OutParam code="{@property}" source="{@property}"/>
              </xsl:if>
            </xsl:for-each>
          </ChangeState>
        </xsl:if>
        <ChangeState id="failed" dataport="insertfailed{@id_cvinclude}" external="yes">
          <xsl:for-each select="Keys/Binding">
            <OutParam code="{@property}" source="XXProp_{@property}" optional="yes"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>
    </xsl:if>

    <Dataport code="insertfailed{@id_cvinclude}">
      <InData>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p2}" optional="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <Call dataport="{@concept}{@id_cvinclude}_CREATE" into="{@concept}{@id_cvinclude}_CREATE">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <SendParam code="{@p2}"/>
          </xsl:for-each>
        </Call>
        <CreateDoc code="navig" doctype="DPNavig"/>

       <xsl:for-each select="ancestor::CVInclude">
          <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
            <xsl:for-each select="$cvirbindings">
              <SendParam code="{@p1}" source="{@p2}"/>
            </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
          </Call>
          <UseDoc code="navig">
            <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
          </UseDoc>
       </xsl:for-each>

      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}{@id_cvinclude}_CREATE"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="insertfailed{@id_cvinclude}.xsl"/>
          <Template href="flapc{@id_cvinclude}.xsl"/>
        </Output>
      </OutData>
    </Dataport>

    </xsl:if>


    <xsl:if test="@delete='1' and $readonly='0'">

    <Dataport code="remove{@id_cvinclude}">
      <InData>
        <xsl:for-each select="Keys/Binding">
          <InParam code="{@property}"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
        <InParam code="style" default="1" optional="yes"/>
      </InData>
      <Process>
        <SessionStore code="style" src="style" scope="dp"/>
        <Call dataport="{@concept}{@id_cvinclude}_EDIT" into="{@concept}_EDIT">
          <xsl:for-each select="Keys/Binding">
            <SendParam code="{@property}"/>
          </xsl:for-each>
        </Call>
        <CreateDoc code="navig" doctype="DPNavig"/>

        <xsl:for-each select="ancestor::CVInclude">
          <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
            <xsl:for-each select="$cvirbindings">
              <SendParam code="{@p1}" source="{@p2}"/>
            </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
          </Call>
          <UseDoc code="navig">
            <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
          </UseDoc>
        </xsl:for-each>

        <UseDoc code="{@concept}_EDIT">
          <AddAttr name="style" src="style"/>
        </UseDoc>

        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='delete'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='delete' and position()&gt;1]">
            <If code="style">
              <xsl:attribute name="contains"><xsl:value-of select="position()+1"/></xsl:attribute>
              <DoOutput>
                <xsl:attribute name="ref">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              </DoOutput>
            </If>
          </xsl:for-each>
        </xsl:if>

        <CreateDoc code="consistency_check" doctype="DPConsistencyCheck"/>
        <xsl:for-each select="ConsistencyChecks/ConsistencyCheck/Works/Work/Includes/Include">
          <UseDoc code="{../../../../../../@concept}_EDIT">
            <GetDoc name="{../../../../../../@conceptcoll}" into="xxxColl"/>
          </UseDoc>
          <UseDoc code="xxxColl">
            <GetDoc name="{../../../../../../@concept}" into="xxxConcept"/>
          </UseDoc>
          <UseDoc code="xxxConcept">
            <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
              <xsl:choose>
                <xsl:when test="@attr='1'">
                  <GetAttr name="{translate(@p2,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}" into="{@p2}"/>
                </xsl:when>
                <xsl:otherwise>
                  <GetElem name="{@p2}" into="{@p2}"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </UseDoc>          
          <Copy target="bindingnotempty" default="true"/>
          <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
            <If code="{@p2}" contains=""><Copy target="bindingnotempty" default="false"/></If>
          </xsl:for-each>
          <If code="bindingnotempty" contains="true">
            <GetData coll="{ancestor::ConsistencyCheck/@conceptcoll}" into="XXC_{ancestor::ConsistencyCheck/@concept}" conceptview="{ancestor::Work/@name}" path="{@path}" rights="true" show="onedit" allkeys="true">
              <Where>
                <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
                  <Eq property="{@p1}" param="{@p2}"/>
                </xsl:for-each>
              </Where>
            </GetData>
          </If>
          <If code="XXC_{ancestor::ConsistencyCheck/@concept}" contains="/{ancestor::ConsistencyCheck/@conceptcoll}/{ancestor::ConsistencyCheck/@concept}">
            <CreateDoc code="check" doctype="ConsistencyCheck"/>
            <UseDoc code="check">
              <AddAttr name="work" default="{ancestor::Work/@name}"/>
              <AddAttr name="include" default="{@id_cvinclude}"/>
              <AddAttr name="association" default="{../../../../@association}"/>
            </UseDoc>
            <ForEach elem="{ancestor::ConsistencyCheck/@concept}" in="XXC_{ancestor::ConsistencyCheck/@concept}" as="{ancestor::ConsistencyCheck/@concept}">
              <CreateDoc code="inconsistency" doctype="Inconsistency"/>
              <xsl:for-each select="ancestor::ConsistencyCheck/KeyProperty">
                <CreateDoc code="keyprop" doctype="KeyProperty"/>
                <UseDoc code="{ancestor::ConsistencyCheck/@concept}">
                  <xsl:choose>
                    <xsl:when test="@attr='1'">
                      <GetAttr name="{translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}" into="val"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <GetElem name="{@name}" into="val"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </UseDoc>
                <UseDoc code="keyprop">
                  <AddAttr name="name" default="{@name}"/>
                  <AddAttr name="value" src="val"/>
                </UseDoc>
                <UseDoc code="inconsistency">
                  <AddDoc src="keyprop"/>
                </UseDoc>
              </xsl:for-each>
              <CreateDoc code="labelprop" doctype="LabelProperty"/>
              <xsl:for-each select="ancestor::ConsistencyCheck/LabelProperty">
                <CreateDoc code="labelprop" doctype="LabelProperty"/>
                <UseDoc code="{ancestor::ConsistencyCheck/@concept}">
                  <xsl:choose>
                    <xsl:when test="@attr='1'">
                      <GetAttr name="{translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}" into="val"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <GetElem name="{@name}" into="val"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </UseDoc>
                <UseDoc code="labelprop">
                  <AddAttr name="name" default="{@name}"/>
                  <AddAttr name="value" src="val"/>
                </UseDoc>
                <UseDoc code="inconsistency">
                  <AddDoc src="labelprop"/>
                </UseDoc>
              </xsl:for-each>
              <UseDoc code="check">
                <AddDoc src="inconsistency"/>
              </UseDoc>
            </ForEach>
            <UseDoc code="consistency_check">
              <AddDoc src="check"/>
            </UseDoc>
          </If>
        </xsl:for-each>

      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}_EDIT"/>
          <OutDoc source="consistency_check" optional="yes"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="{$ro_redir}delete{@id_cvinclude}.xsl" hrefparam="ssnstldlt" hrefsuffix="{@id_cvinclude}.xsl"/>
          <Template href="{$ro_redir}flape{@id_cvinclude}.xsl"/>
        </Output>
        <xsl:if test="count(CVIStyles/CVIStyle[Style/StyleType/@name='delete'])&gt;1">
          <xsl:for-each select="CVIStyles/CVIStyle[Style/StyleType/@name='delete' and position()&gt;1]">
            <Output>
              <xsl:attribute name="id">style<xsl:value-of select="position()+1"/>alt</xsl:attribute>
              <OutDoc source="{../../@concept}_EDIT"/>
              <OutDoc source="navig" optional="yes"/>
              <Template href="/header.xsl"/>
              <Template hrefparam="ssnstldlt">
                <xsl:attribute name="href">delete<xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
                <xsl:attribute name="hrefsuffix"><xsl:value-of select="position()+1"/>alt<xsl:value-of select="@id_cvinclude"/>.xsl</xsl:attribute>
              </Template>
              <Template href="{$ro_redir}flape{../../@id_cvinclude}.xsl"/>
            </Output>
          </xsl:for-each>
        </xsl:if>
      </OutData>
    </Dataport>

    <xsl:choose>
    <xsl:when test="name(..)!='CView'">

    <Dataport code="delete{@id_cvinclude}">
      <InData>
        <InDoc code="{@concept}" doctype="{@concept}" nickname="{@nickname}" concept="yes"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <xsl:if test="name(..)!='CView' and ancestor::CView/CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']">
          <UseDoc code="{@concept}">
            <GetAttr into="child" name="{ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding/@p2}"/>
          </UseDoc>
        </xsl:if>
        <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <If code="{@path}" contains="/{@concept}">              
            <DeleteData concept="{@concept}" with="{@path}" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
          </If>
        </xsl:for-each>
        -->
        <If code="{@concept}" contains="/{@concept}">
          <UseDoc code="{@concept}">
            <xsl:for-each select="Keys/Binding">
              <GetAttr name="{@property}" into="XXProp_{@property}"/>
            </xsl:for-each>
            <xsl:for-each select="../CVIRBindings/CVIRBinding">
              <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                <GetAttr name="{@p2}" into="XXProp_{@p2}"/>
              </xsl:if>
            </xsl:for-each>
          </UseDoc>
          <xsl:for-each select="Keys/Binding">
           <If code="XXProp_{@property}" contains="">
             <DoOutput ref="missingkey"/>
           </If>
          </xsl:for-each>
          <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" show="onedit" allkeys="true">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="{@property}" param="XXProp_{@property}"/>
              </xsl:for-each>
            </Where>
          </GetData>
          <DeleteData concept="{@concept}" with="XXC_{@concept}" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
        </If>

        <!-- attempt to find and update root of a recursive view -->
        <xsl:if test="name(..)!='CView' and ancestor::CView/CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']">
          <Call dataport="updrecroot" into="updrecrootres">
             <SendParam code="child" source="child"/>
          </Call>
        </xsl:if>

      </Process>
      <OutData type="html">
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <OutParam code="{@p1}" source="XXProp_{@p2}"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>

    <Dataport code="deletewc{@id_cvinclude}">
      <InData>
        <InDoc code="{@concept}" doctype="{@concept}" nickname="{@nickname}" concept="yes"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <xsl:if test="name(..)!='CView' and ancestor::CView/CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']">
          <UseDoc code="{@concept}">
            <GetAttr into="child" name="{ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding/@p2}"/>
          </UseDoc>
        </xsl:if>
        <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <If code="{@path}" contains="/{@concept}">               
            <DeleteData concept="{@concept}" with="{@path}" work="{../../../@coverer}" workpath="{@rootnickpath}"/>
          </If>
        </xsl:for-each>
        -->
        <If code="{@concept}" contains="/{@concept}">
          <UseDoc code="{@concept}">
            <xsl:for-each select="Keys/Binding">
              <GetAttr name="{@property}" into="XXProp_{@property}"/>
            </xsl:for-each>
            <xsl:for-each select="../CVIRBindings/CVIRBinding">
              <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                <GetAttr name="{@p2}" into="XXProp_{@p2}"/>
              </xsl:if>
            </xsl:for-each>
          </UseDoc>
          <xsl:for-each select="Keys/Binding">
           <If code="XXProp_{@property}" contains="">
             <DoOutput ref="missingkey"/>
           </If>
          </xsl:for-each>
          <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{@coverer}" path="{@covrootpath}" rights="true" show="onedit" allkeys="true">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="{@property}" param="XXProp_{@property}"/>
              </xsl:for-each>
            </Where>
          </GetData>
          <DeleteData concept="{@concept}" with="XXC_{@concept}" work="{@coverer}" workpath="{@covrootpath}"/>
        </If>

        <!-- attempt to find and update root of a recursive view -->
        <xsl:if test="name(..)!='CView' and ancestor::CView/CVInclude/CVIRels/CVIRel/CVInclude[CVIRels/CVIRel/CVInclude/@path='../..']">
          <Call dataport="updrecroot" into="updrecrootres">
             <SendParam code="child" source="child"/>
          </Call>
        </xsl:if>

      </Process>
      <OutData type="html">
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <OutParam code="{@p1}" source="XXProp_{@p2}"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>

    <xsl:if test="@deletecoll='1' and $readonly='0'">
    <Dataport code="deletecoll{@id_cvinclude}">
      <InData>
        <InDoc code="{@conceptcoll}" doctype="{@conceptcoll}" nickname="{@nickcoll}"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}s" doctype="{@concept}s" nickname="{@path}s"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
      <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <ForEach elem="{@concept}" in="{@path}s" as="{@path}">
            <If code="{@path}" contains="/{@concept}"> 
              <DeleteData concept="{@concept}" with="{@path}" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
            </If>
          </ForEach>
        </xsl:for-each>
       -->
        <If code="{@conceptcoll}" contains="/{@conceptcoll}">
          <ForEach elem="{@concept}" in="{@conceptcoll}" as="{@concept}">
            <UseDoc code="{@concept}">
              <xsl:for-each select="Keys/Binding">
                <GetAttr name="{@property}" into="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <GetAttr name="{@p2}" into="XXProp_{@p2}"/>
                </xsl:if>
              </xsl:for-each>
            </UseDoc>
            <xsl:for-each select="Keys/Binding">
             <If code="XXProp_{@property}" contains="">
               <DoOutput ref="missingkey"/>
             </If>
            </xsl:for-each>
            <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" show="onedit" allkeys="true">
              <Where>
                <xsl:for-each select="Keys/Binding">
                  <Eq property="{@property}" param="XXProp_{@property}"/>
                </xsl:for-each>
              </Where>
            </GetData>
            <DeleteData concept="{@concept}" with="XXC_{@concept}" work="{ancestor::CView/@name}" workpath="{@rootnickpath}"/>
          </ForEach>
        </If>
      </Process>
      <OutData type="html">
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <OutParam code="{@p1}" source="XXProp_{@p2}"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>
    <Dataport code="deletecollwc{@id_cvinclude}">
      <InData>
        <InDoc code="{@conceptcoll}" doctype="{@conceptcoll}" nickname="{@nickcoll}"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}s" doctype="{@concept}s" nickname="{@path}s"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
      <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <ForEach elem="{@concept}" in="{@path}s" as="{@path}">
            <If code="{@path}" contains="/{@concept}">
              <DeleteData concept="{@concept}" with="{@path}" work="{../../../@coverer}" workpath="{@rootnickpath}"/>
            </If>
          </ForEach>
        </xsl:for-each>
        -->
        <If code="{@conceptcoll}" contains="/{@conceptcoll}">
          <ForEach elem="{@concept}" in="{@conceptcoll}" as="{@concept}">
            <UseDoc code="{@concept}">
              <xsl:for-each select="Keys/Binding">
                <GetAttr name="{@property}" into="XXProp_{@property}"/>
              </xsl:for-each>
              <xsl:for-each select="../CVIRBindings/CVIRBinding">
                <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
                  <GetAttr name="{@p2}" into="XXProp_{@p2}"/>
                </xsl:if>
              </xsl:for-each>
            </UseDoc>
            <xsl:for-each select="Keys/Binding">
             <If code="XXProp_{@property}" contains="">
               <DoOutput ref="missingkey"/>
             </If>
            </xsl:for-each>

            <Call dataport="{@concept}{@id_cvinclude}_EDIT" into="{@concept}_EDIT">
              <xsl:for-each select="Keys/Binding">
                <SendParam code="{@property}"/>
              </xsl:for-each>
            </Call>
            <Copy target="test" default="ok"/>           
            <xsl:for-each select="ConsistencyChecks/ConsistencyCheck/Works/Work/Includes/Include">
              <UseDoc code="{../../../../../../@concept}_EDIT">
                <GetDoc name="{../../../../../../@conceptcoll}" into="xxxColl"/>
              </UseDoc>
              <UseDoc code="xxxColl">
                <GetDoc name="{../../../../../../@concept}" into="xxxConcept"/>
              </UseDoc>
              <UseDoc code="xxxConcept">
                <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
                  <xsl:choose>
                    <xsl:when test="@attr='1'">
                      <GetAttr name="{translate(@p2,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}" into="{@p2}"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <GetElem name="{@p2}" into="{@p2}"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </xsl:for-each>
              </UseDoc>
              <GetData coll="{ancestor::ConsistencyCheck/@conceptcoll}" into="XXC_{ancestor::ConsistencyCheck/@concept}" conceptview="{ancestor::Work/@name}" path="{@path}" rights="true" show="onedit" allkeys="true">
                <Where>
                  <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
                    <Eq property="{@p1}" param="{@p2}"/>
                  </xsl:for-each>
                </Where>
              </GetData>
              <If code="XXC_{ancestor::ConsistencyCheck/@concept}" contains="/{ancestor::ConsistencyCheck/@conceptcoll}/{ancestor::ConsistencyCheck/@concept}">
                <Copy target="test" default="fail"/>
              </If>
            </xsl:for-each>
            <If code="test" contains="ok">            
              <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{@coverer}" path="{@covrootpath}" rights="true" show="onedit" allkeys="true">
                <Where>
                  <xsl:for-each select="Keys/Binding">
                    <Eq property="{@property}" param="XXProp_{@property}"/>
                  </xsl:for-each>
                </Where>
              </GetData>
              <DeleteData concept="{@concept}" with="XXC_{@concept}" work="{@coverer}" workpath="{@covrootpath}"/>          
            </If>            
          </ForEach>
        </If>
      </Process>
      <OutData type="html">
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <OutParam code="{@p1}" source="XXProp_{@p2}"/>
          </xsl:for-each>
          <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>
    </xsl:if>

    </xsl:when>
    <xsl:otherwise>

    <Dataport code="delete{@id_cvinclude}">
      <InData>
        <InDoc code="{@concept}" doctype="{@concept}" nickname="{@nickname}" concept="yes"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <If code="{@path}" contains="/{@concept}">       
            <DeleteData concept="{@concept}" with="{@path}" work="{ancestor::CView/@name}" workpath="{../../../@covrootpath}"/>
          </If>
        </xsl:for-each>
        -->
        <UseDoc code="{@concept}">
          <xsl:for-each select="Keys/Binding">
            <GetAttr name="{@property}" into="{@property}"/>
          </xsl:for-each>
        </UseDoc>
        <xsl:for-each select="Keys/Binding">
         <If code="{@property}" contains="">
           <DoOutput ref="missingkey"/>
         </If>
        </xsl:for-each>
        <GetData conceptview="{ancestor::CView/@name}" into="{ancestor::CView/@name}" rights="true" show="onlabel">
          <Where>
            <xsl:for-each select="Keys/Binding">
              <Eq property="/{../../@nickname}/{@property}" param="{@property}"/>
            </xsl:for-each>
          </Where>
        </GetData>
        <DeleteData conceptview="{ancestor::CView/@name}" with="{ancestor::CView/@name}"/>
      </Process>
      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>

    <Dataport code="deletewc{@id_cvinclude}">
      <InData>
        <InDoc code="{@concept}" doctype="{@concept}" nickname="{@nickname}" concept="yes"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}" doctype="{@concept}" nickname="{@path}" concept="yes"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
      <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <If code="{@path}" contains="/{@concept}">            
            <DeleteData concept="{@concept}" with="{@path}" work="{../../../@coverer}" workpath="{@rootnickpath}"/>
          </If>
        </xsl:for-each>
        -->
        <UseDoc code="{@concept}">
          <xsl:for-each select="Keys/Binding">
            <GetAttr name="{@property}" into="{@property}"/>
          </xsl:for-each>
        </UseDoc>
        <xsl:for-each select="Keys/Binding">
         <If code="{@property}" contains="">
           <DoOutput ref="missingkey"/>
         </If>
        </xsl:for-each>
        <xsl:choose>
          <xsl:when test="@covrootpath=concat('/',@concept)">
            <GetData into="{@coverer}" rights="true" show="onlabel" conceptview="{@coverer}">
              <Where>
                <xsl:for-each select="Keys/Binding">
                  <Eq property="/{../../@nickname}/{@property}" param="{@property}"/>
                </xsl:for-each>
                <xsl:if test="@xxxrecursive='yes'">
                  <Eq property="xxxisroot" default="1"/>
                </xsl:if>
              </Where>
            </GetData>
            <DeleteData with="{@coverer}" conceptview="{@coverer}">
            </DeleteData>
          </xsl:when>
          <xsl:otherwise>
            <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{@coverer}" path="{@covrootpath}" rights="true" show="onedit" allkeys="true">
              <Where>
                <xsl:for-each select="Keys/Binding">
                  <Eq property="{@property}" param="{@property}"/>
                </xsl:for-each>
              </Where>
            </GetData>
            <DeleteData concept="{@concept}" with="XXC_{@concept}" work="{@coverer}" workpath="{@covrootpath}"/>          
          </xsl:otherwise>
        </xsl:choose>
      </Process>
      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>

    <xsl:if test="@deletecoll='1' and $readonly='0'">
    <Dataport code="deletecoll{@id_cvinclude}">
      <InData>
        <InDoc code="{@conceptcoll}" doctype="{@conceptcoll}" nickname="{@nickcoll}"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}s" doctype="{@concept}s" nickname="{@path}s"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
        <!--        
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <ForEach elem="{@concept}" in="{@path}s" as="{@path}">
            <If code="{@path}" contains="/{@concept}"> 
              <DeleteData concept="{@concept}" with="{@path}" work="{ancestor::CView/@name}" workpath="{../../../@covrootpath}"/>
            </If>
          </ForEach>
        </xsl:for-each>
        -->
        <ForEach elem="{@concept}" in="{@conceptcoll}" as="{@concept}">
          <UseDoc code="{@concept}">
            <xsl:for-each select="Keys/Binding">
              <GetAttr name="{@property}" into="{@property}"/>
            </xsl:for-each>
          </UseDoc>
          <xsl:for-each select="Keys/Binding">
           <If code="{@property}" contains="">
             <DoOutput ref="missingkey"/>
           </If>
          </xsl:for-each>

          <GetData conceptview="{ancestor::CView/@name}" into="{ancestor::CView/@name}" rights="true" show="onlabel">
            <Where>
              <xsl:for-each select="Keys/Binding">
                <Eq property="/{../../@nickname}/{@property}" param="{@property}"/>
              </xsl:for-each>
            </Where>
          </GetData>
          <DeleteData conceptview="{ancestor::CView/@name}" with="{ancestor::CView/@name}"/>
        </ForEach>

      </Process>
      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>
    <Dataport code="deletecollwc{@id_cvinclude}">
      <InData>
        <InDoc code="{@conceptcoll}" doctype="{@conceptcoll}" nickname="{@nickcoll}"/>
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <InDoc code="{@path}s" doctype="{@concept}s" nickname="{@path}s"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
      </InData>
      <Process>
      <!--
        <xsl:for-each select="Schedules/DeleteVirtualSchedule/SchedItem[@reltype='1:1']">
          <ForEach elem="{@concept}" in="{@path}s" as="{@path}">
            <If code="{@path}" contains="/{@concept}"> 
              <DeleteData concept="{@concept}" with="{@path}" work="{../../../@coverer}" workpath="{@rootnickpath}"/>
            </If>
          </ForEach>
        </xsl:for-each>
       -->
        <ForEach elem="{@concept}" in="{@conceptcoll}" as="{@concept}">
          <UseDoc code="{@concept}">
            <xsl:for-each select="Keys/Binding">
              <GetAttr name="{@property}" into="{@property}"/>
            </xsl:for-each>
          </UseDoc>
          <xsl:for-each select="Keys/Binding">
           <If code="{@property}" contains="">
             <DoOutput ref="missingkey"/>
           </If>
          </xsl:for-each>

          <Call dataport="{@concept}{@id_cvinclude}_EDIT" into="{@concept}_EDIT">
            <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}"/>
            </xsl:for-each>
          </Call>
          <Copy target="test" default="ok"/>           
          <xsl:for-each select="ConsistencyChecks/ConsistencyCheck/Works/Work/Includes/Include">
            <UseDoc code="{../../../../../../@concept}_EDIT">
              <GetDoc name="{../../../../../../@conceptcoll}" into="xxxColl"/>
            </UseDoc>
            <UseDoc code="xxxColl">
              <GetDoc name="{../../../../../../@concept}" into="xxxConcept"/>
            </UseDoc>
            <UseDoc code="xxxConcept">
              <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
                <xsl:choose>
                  <xsl:when test="@attr='1'">
                    <GetAttr name="{translate(@p2,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}" into="{@p2}"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <GetElem name="{@p2}" into="{@p2}"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:for-each>
            </UseDoc>
            <GetData coll="{ancestor::ConsistencyCheck/@conceptcoll}" into="XXC_{ancestor::ConsistencyCheck/@concept}" conceptview="{ancestor::Work/@name}" path="{@path}" rights="true" show="onedit" allkeys="true">
              <Where>
                <xsl:for-each select="ancestor::ConsistencyCheck/Binding">
                  <Eq property="{@p1}" param="{@p2}"/>
                </xsl:for-each>
              </Where>
            </GetData>
            <If code="XXC_{ancestor::ConsistencyCheck/@concept}" contains="/{ancestor::ConsistencyCheck/@conceptcoll}/{ancestor::ConsistencyCheck/@concept}">
              <Copy target="test" default="fail"/>
            </If>
          </xsl:for-each>
          <If code="test" contains="ok">            
            <xsl:choose>
              <xsl:when test="@covrootpath=concat('/',@concept)">
                <GetData conceptview="{@coverer}" into="{@coverer}" rights="true" show="onlabel">
                  <Where>
                    <xsl:for-each select="Keys/Binding">
                      <Eq property="/{../../@nickname}/{@property}" param="{@property}"/>
                    </xsl:for-each>
                  </Where>
                </GetData>
                <DeleteData conceptview="{@coverer}" with="{@coverer}" work="{@coverer}" workpath="{@covrootpath}"/>          
              </xsl:when>
              <xsl:otherwise>
                <GetData coll="{@conceptcoll}" into="XXC_{@concept}" conceptview="{@coverer}" path="{@covrootpath}" rights="true" show="onedit" allkeys="true">
                  <Where>
                    <xsl:for-each select="Keys/Binding">
                      <Eq property="{@property}" param="{@property}"/>
                    </xsl:for-each>
                  </Where>
                </GetData>
                <DeleteData concept="{@concept}" with="XXC_{@concept}" work="{@coverer}" workpath="{@covrootpath}"/>          
              </xsl:otherwise>
            </xsl:choose>
          </If>
        </ForEach>

      </Process>
      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
        <ChangeState id="missingkey" dataport="list{@id_cvinclude}" external="yes">
         <xsl:for-each select="ancestor-or-self::CVInclude/../CVIRBindings/CVIRBinding">
            <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
              <OutParam code="{@p1}" source="{@p1}"/>
            </xsl:if>
          </xsl:for-each>
          <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
            <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
            <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
              <OutParam code="{@property}" source="{@property}"/>
            </xsl:if>
          </xsl:for-each>
        </ChangeState>
      </OutData>
    </Dataport>
    </xsl:if>

    </xsl:otherwise>
    </xsl:choose>

    </xsl:if>

    <xsl:if test="Catalog">

      <Dataport code="{@concept}_CAT">
        <InData>
          <InParam code="{@concept}.step" default="{$pagelen}"/>
          <InParam code="{@concept}.start" optional="yes"/>
          <InParam code="{@concept}.orderby" optional="yes"/>
          <InParam code="{@concept}.order" optional="yes"/>
          <xsl:for-each select="Keys/Binding">
            <InParam code="{@property}"/>
          </xsl:for-each>
        </InData>
        <Process>

          <GetData conceptview="{ancestor::CView/@name}" path="{@rootnickpath}" rights="true" into="subcats" distinct="{$isdistinct}" allkeys="true">
            <Properties>
              <xsl:for-each select="CVIProperties/CVIProperty[PropGroup/@basegroup='true' and (@key='1' or @onlabel='1')]">
                <xsl:variable name="attr">
                  <xsl:choose>
                    <xsl:when test="@attr='1'">true</xsl:when>
                    <xsl:otherwise>false</xsl:otherwise>
                  </xsl:choose>
                </xsl:variable>
                <xsl:choose>
                  <xsl:when test="RefProp and @onlist='show'">
                    <Property name="{@name}" attr="{$attr}"/>
                    <xsl:for-each select="RefProp">
                      <xsl:variable name="rattr">
                        <xsl:choose>
                          <xsl:when test="@attr='1'">true</xsl:when>
                          <xsl:otherwise>false</xsl:otherwise>
                        </xsl:choose>
                      </xsl:variable>
                      <Property name="{@refconcept}/{@code}" nickname="{@nickname}" attr="{$rattr}"/>
                    </xsl:for-each>
                  </xsl:when>
                  <xsl:otherwise>
                    <Property name="{@name}" attr="{$attr}"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:for-each>
            </Properties>
            <Relates>
              <Relate from="." to="{Catalog/@relconcept}">
                <xsl:for-each select="Catalog/Backwards/Relate">
                  <Binding from="{@p2}" to="{@p1}"/>
                </xsl:for-each>
              </Relate>
            </Relates>
            <Where>
              <xsl:for-each select="Catalog/CVIRBindings/CVIRBinding">
                <Eq property="{../../@relconcept}/{@p2}" param="{@p1}"/>
              </xsl:for-each>
            </Where>
          </GetData>
          <CreateDoc code="res" doctype="DPCat"/>
          <UseDoc code="res">
            <AddDoc src="subcats"/>
          </UseDoc>
        </Process>
        <OutData type="xml">
          <Output source="res"/>
        </OutData>
      </Dataport>
    </xsl:if>


    <xsl:if test="name(..)='CView'">

    <Dataport code="ifacedef">
      <InData>
      </InData>
      <Process>
        <CreateDoc code="doc" doctype="IfaceDef"/>
      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="doc"/>
          <Template href="/header.xsl"/>
          <Template href="{$ro_redir}ifacedef.xsl"/>
        </Output>
      </OutData>
    </Dataport>

    <xsl:if test="@allowxml='1'">

    <Dataport code="edtxml">
      <InData>
        <xsl:for-each select="Keys/Binding">
          <InParam code="{@property}"/>
        </xsl:for-each>
      </InData>
      <Process>
        <xsl:for-each select="Keys/Binding">
          <SessionStore code="{@property}" src="{@property}" scope="dp"/>
        </xsl:for-each>
        <Call dataport="{@concept}{@id_cvinclude}_EDIT" into="{@concept}_EDIT">
          <xsl:for-each select="Keys/Binding">
            <SendParam code="{@property}"/>
          </xsl:for-each>
        </Call>        

        <GetData into="{@concept}" conceptview="{@coverer}" nohiddenkeys="true" rights="true">
          <xsl:attribute name="show">
            <xsl:choose>
              <xsl:when test="@update='1' and $readonly='0'">onedit</xsl:when>
              <xsl:otherwise>ondetail</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
          <Where>
            <xsl:for-each select="Keys/Binding">
              <Eq property="{@property}" param="{@property}"/>
            </xsl:for-each>
          </Where>
        </GetData>
              
      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}"/>
          <OutDoc source="{@concept}_EDIT"/>
          <Template href="/header.xsl"/>
          <Template href="edtxml.xsl"/>
          <Template href="{$ro_redir}flape{@id_cvinclude}.xsl"/>
        </Output>
      </OutData>
    </Dataport>


    <Dataport code="nokeysxml">
      <InData>
        <xsl:for-each select="Keys/Binding">
          <InParam code="{@property}"/>
        </xsl:for-each>
      </InData>
      <Process>
        <xsl:for-each select="Keys/Binding">
          <SessionStore code="{@property}" src="{@property}" scope="dp"/>
        </xsl:for-each>
        <Call dataport="{@concept}{@id_cvinclude}_EDIT" into="{@concept}_EDIT">
          <xsl:for-each select="Keys/Binding">
            <SendParam code="{@property}"/>
          </xsl:for-each>
        </Call>
        <GetData into="{@concept}" conceptview="{@coverer}" nokeys="true" nohiddenkeys="true" rights="true">
          <Where>
            <xsl:for-each select="Keys/Binding">
              <Eq property="{@property}" param="{@property}"/>
            </xsl:for-each>
          </Where>
        </GetData>
      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{@concept}"/>
          <OutDoc source="{@concept}_EDIT"/>
          <Template href="/header.xsl"/>
          <Template href="{$ro_redir}nokeysxml.xsl"/>
          <Template href="{$ro_redir}flape{@id_cvinclude}.xsl"/>
        </Output>
      </OutData>
    </Dataport>


    <xsl:if test="@update='1' and $readonly='0'">
    <Dataport code="updatexml">
      <InData>
        <InDoc code="indoc" doctype="coverer_{@concept}"/>
      </InData>
      <Process>
        <Transaction>
          <UpdateData conceptview="coverer_{@concept}" with="indoc" update="yes" insert="no" work="{ancestor::CView/@name}" rights="true"/>
        </Transaction>
      </Process>
      <OutData type="html">
        <xsl:choose>
          <xsl:when test="count(CVIRels/CVIRel/CVInclude[@virtual='0' and (@hasflap='1' or not(@hasflap))])>0">
            <ChangeState dataport="edit{@id_cvinclude}" external="yes">
            </ChangeState>
          </xsl:when>
          <xsl:otherwise>
            <ChangeState dataport="list{@id_cvinclude}" external="yes">
            </ChangeState>
          </xsl:otherwise>
        </xsl:choose>
      </OutData>
    </Dataport>
    </xsl:if>

    <xsl:if test="@create='1' and $readonly='0'">
    <Dataport code="crtxml">
      <InData>
      </InData>
      <Process>
        <CreateDoc code="navig" doctype="DPNavig"/>
        <CreateDoc code="{ancestor::CView/@name}" doctype="coverer_{@concept}"/>
      </Process>
      <OutData type="html">
        <Output>
          <OutDoc source="{ancestor::CView/@name}" optional="yes"/>
          <OutDoc source="navig" optional="yes"/>
          <Template href="/header.xsl"/>
          <Template href="crtxml.xsl"/>
          <Template href="flapc{@id_cvinclude}.xsl"/>
        </Output>
      </OutData>
    </Dataport>

    <Dataport code="createxml">
      <InData>
        <InDoc code="indoc" doctype="coverer_{@concept}"/>
      </InData>
      <Process>
        <Transaction>
          <UpdateData conceptview="{@coverer}" with="indoc" update="no" insert="yes" work="{ancestor::CView/@name}" rights="true"/>
        </Transaction>
      </Process>
      <OutData type="html">
        <ChangeState dataport="list{@id_cvinclude}" external="yes"/>
      </OutData>
    </Dataport>
    </xsl:if>

    </xsl:if>

    </xsl:if>


  <Dataport code="expxls{@id_cvinclude}">
    <InData>
      <InData>
        <InParam code="{@concept}.step" default="{$pagelen}"/>
        <xsl:for-each select="../CVIRBindings/CVIRBinding">
          <InParam code="{@p1}"/>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/../CVIRBindings/CVIRBinding">
          <xsl:if test="not(../../CVInclude/Keys/Binding[@property=current()/@p2])">
            <InParam code="{@p1}"/>
          </xsl:if>
        </xsl:for-each>
        <xsl:for-each select="ancestor::CVInclude/Keys/Binding">
          <xsl:variable name="property"><xsl:value-of select="@property"/></xsl:variable>
          <xsl:if test="not(../../CVIRels/CVIRel[descendant::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding[@p1=$property])">
            <InParam code="{@property}"/>
          </xsl:if>
        </xsl:for-each>
        <InParam code="{@concept}.start" optional="yes"/>
        <InParam code="{@concept}.orderby" optional="yes"/>
        <InParam code="{@concept}.order" optional="yes"/>
        <InDoc doctype="DPFilter" code="{@concept}.filter" optional="yes"/>
        <InParam code="setfilter" optional="yes"/>
        <InParam code="select" default="no"/>
      </InData>
    </InData>
    <Process>
        <Copy target="{@concept}.step" default="10000"/>
        <Call dataport="{@concept}{@id_cvinclude}_EXPLIST" into="{@concept}{@id_cvinclude}_LIST">
          <xsl:for-each select="../CVIRBindings/CVIRBinding">
            <SendParam code="{@p2}" source="{@p1}"/>
          </xsl:for-each>
          <SendParam code="{@concept}.start" optional="yes"/>
          <SendParam code="{@concept}.step" optional="yes"/>
          <SendParam code="{@concept}.orderby" optional="yes"/>
          <SendParam code="{@concept}.order" optional="yes"/>
          <SendParam code="{@concept}.filter" optional="yes"/>
          <SendParam code="select" default="no"/>
        </Call>
        <CreateDoc code="navig" doctype="DPNavig"/>
        <xsl:for-each select="ancestor::CVInclude">
           <Call dataport="{@concept}{$id_cvincludeparent}_{@id_cvinclude}_KEYS_LBLS" into="{@concept}{@id_cvinclude}_KEYS">
             <xsl:for-each select="$cvirbindings">
               <SendParam code="{@p1}"/>
             </xsl:for-each>
             <xsl:variable name="xcvi" select="@id_cvinclude"/>
             <xsl:if test="@id_cvinclude!=$id_cvincludeparent">
               <xsl:for-each select="CVIRels/CVIRel[descendant-or-self::CVInclude/@id_cvinclude=$id_cvinclude]/CVIRBindings/CVIRBinding">
                 <xsl:variable name="xp2" select="@p2"/>
                 <xsl:if test="not(../../CVInclude/Keys/Binding[@property=$xp2])">
                   <SendParam code="{@p1}"/>
                 </xsl:if>
               </xsl:for-each>
             </xsl:if>
             <xsl:for-each select="Keys/Binding">
              <SendParam code="{@property}" optional="yes"/>
             </xsl:for-each>
           </Call>
           <UseDoc code="navig">
             <AddDoc src="{@concept}{@id_cvinclude}_KEYS"/>
           </UseDoc>
        </xsl:for-each>
    </Process>
    <OutData type="application/vnd.ms-excel">
      <Output>
        <OutDoc source="navig" optional="yes"/>
        <OutDoc source="{@concept}{@id_cvinclude}_LIST"/>
        <Template href="{$ro_redir}expxls{@id_cvinclude}.xsl"/>
      </Output>
    </OutData>
  </Dataport>

 </xsl:template>


</xsl:stylesheet>


 
